Command Line Interface :

Manav GuptaManav Gupta
3 min read

In today’s fast-growing world. It’s necessary to know about CLI. If you are a Developer knowing about your terminal can increase your efficiency, boost your problem-solving ability, and to understand how the system works.

In this blog, we will understand we will explore essential CLI commands we should know.

What is a command Line Interface?

The shell provides an interface to Linux where you can type or enter commands using the keyboard. It is known as the command-line interface (CLI). It allows users to execute commands and scripts to perform tasks, automate processes, and manage system resources.

Benefits of using CLI Commands :

  1. Speed: CLI tasks are faster than navigating GUIs

  2. Automation: Scripts can automate repetitive tasks, saving time and effort.

  3. Efficiency: CLIs can be faster than GUIs for certain tasks, especially when working with multiple files or running scripts

  4. Accessibility: Some tools and services only offer a CLI interface.

How Does CLI Work?

  1. You type a command in the terminal.

  2. The shell reads it: The shell is a program that reads your command and figures out what you want.

  3. The shell sends instructions to the OS: Based on what you typed it tells the OS what to do.

  4. The OS does the task.

  5. The shell shows the result.

Some Basic CLI Commands:

Bread and Butter Commands - all important:

  1. man:

    Usage: Shows the manual for any command.

    Example: man ls

  1. cd :

    Usage: Changing directories.

    Example: cd dir1.

  2. mkdir

    Usage: Creating directories.

    Example: mkdir dir1.

  3. mv

    Usage: Move or rename files.

    Example: mv file1.txt dir1/

  4. cp

    Usage: Copy files or directories.

    Example: cp -r dir1 dir2.

  5. ls

    Usage: List directory contents.

    Common flags:

    -a: show hidden files

    -t: sort by time

    -r: reverse order

    -lh: long list with human-readable sizes

  6. pwd

    Usage: Shows present working directories

  7. chmod

    Usage: Change file permissions.

    Example: chmod 755 a.text

  1. ps, top

    ps - view processes

    top -real-time system monitoring

  2. df, free

    df - disk usage

    free - RAM usage

  3. uname

    Usage: System Information

    Example: uname -a

  4. lspci

    Usage: List PCI devices (including sound, and network cards).

  1. ping, ifconfig, ssh

    ping: test network

    ifconfig: network config

    ssh: remote login

Tips for Using Command Line Interface :

  • Tab: Auto-completes file and folder names

  • Piping: Use the pipe symbol (|) to connect commands and process output.

  • history: Shows all the commands you’ve typed recently.

  • Ctrl + L: clears the terminal screen.

  • Practice: Experiment with different commands and explore the possibilities of automation.

What is the shell?

  1. Shell = the middleman between you and the OS.

  2. Popular shells you might hear about:

    • Bash (Bourne Again Shell) is → most common.

    • zsh (Z Shell) → fancier, customizable.

    • fish (Friendly Interactive Shell) → very beginner-friendly

  3. If you wanna about your current shell type the below command in your shell

    cat /etc/shells

Conclusion

The CLI is a valuable tool for developers, system administrators, and anyone who needs precise control and automation capabilities. While GUIs are more common for general use, CLIs remain essential for specific tasks and remain a powerful interface for interacting with computer systems.

Remember: Every tech giant you admire started by typing ls for the first time.

0
Subscribe to my newsletter

Read articles from Manav Gupta directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Manav Gupta
Manav Gupta