Linux command line

Deepak Gupta
Deepak Gupta December 9, 2021
Updated 2021/12/09 at 2:26 PM

The Linux command line is a text-based system that enters commands to the computer and returns results to the user. By the late 1990s, it was nearly impossible to use Linux without relying on a specific command line. Since that time, things have changed considerably, now you can use the Linux desktop without having to type a single command.

While that evolution is useful for onboarding new users to the open source fold, it avoids a very true truth, the command line offers a significant amount of power and flexibility to the operating system. This is valid for Linux, Windows and MacOS. And while some commands are incredibly complex, most are not. Keep reading…

What is the CLI?

CLI means Command Line Interface which is used to execute actual commands. It is made up of two distinct components:

  • Shell: Which is an interpreter that can transform what you write into something usable by the operating system. Linux supports several different shells, the most common being bash (which stands for Bourne Again Shell). Without the shell, what you type at the command prompt would not be usable by the operating system.
  • Terminal emulator: This small window emulates a Linux terminal. Most of the time Linux servers do not include a desktop, so when you log into such a machine, you are greeted with a terminal that includes a shell command prompt and no more. In a system with a desktop, that terminal has to be emulated. Applications like GNOME Terminal, Konsole and LXTerminal offer you this specific functionality.

Why use the CLI?

If you are using Linux on the desktop, the chances that you will need to use the CLI are not as great as they would be if you were working on a server. If you are working on a Linux server, you generally only use a command prompt to interact with the operating system. However, making use of the CLI is an efficient means of handling many tasks. Plus, making your life more efficient, it also brings a level of flexibility to the desktop that you won’t find in GUI tools. Although you will find a GUI tool for every task you run on Linux, some of those graphical interfaces do not cover all of what the CLI option offers. For example: most Linux desktops use pulseaudio for multimedia and system sound.

One thing you can’t do, however, is restart the pulseaudio daemon from the GUI. In some cases pulseaudio must be restarted. Instead of restarting your computer, you can try opening a terminal emulator and issuing the command:

pulseaudio -k

That is not something you can do from the desktop configuration tool.

How to run the commands?

Most commands in Linux are global or general, which means that you can run any command you want (as long as you have permission to do so) from anywhere you understand. So if you need to list the contents of a directory, open a terminal emulator and run the command:


Because the command is global (system installed on the entire system), you don’t have to publish the full path of the command:

Most of the commands can be run alternately, which is what makes the CLI so powerful. The standard format for a command that is run with options is the command string followed by its options. Following our ls example, let’s say you want to see more information about the files and folders within a specific location. For that, you can add the -l option (which is for a long list). This new command would be:

ls -l
The -l option tells ls to also list information such as permissions, owner, group, size, creation date, and name. You can also add hidden files (files that start with a.) With the -a option to the command. To make that last command more efficient, you can combine options together, as in:

Command permissions

Some commands can only be executed correctly by users with superuser permissions. For example, restarting a computer requires elevated permissions. You cannot open a terminal emulator and issue the command restart without being informed that you do not have the administrator permissions.
To execute commands that require administrator permissions, you will have to use a tool like sudo. To successfully reboot a Linux computer from the CLI, that command would be sudo restart
Sudo allows normal user accounts to run commands with superuser privileges. Always use sudo with caution. For example, if you were to run the command: sudo rm -rf / it would delete everything on your system. This would render your system completely unusable (requiring you to reinstall the operating system). That’s how powerful the CLI can be.

Commands Every Beginner Might Want to Know

There are endless commands that every novice Linux user must know in order to properly interact with the system. These commands are not challenging and can make your daily life a little more efficient. To create a new directory, use the command mkdir. For example, to create a new directory named data In the main directory, open a terminal emulator and run the command:

mkdir /home/USER/data

(Username is your username). You can make that command easier to type by using the parent directory shortcut, // (taking the place of / home / USER /).

To move to that newly created directory, issue the command cd data. This command assumes that it is already in your home directory. If you are in any other directory on your system, use the shortcut / home / USER /:
If you’re not sure what directory it is in, run the command pwd(which means “print working directory”) to print the name of the directory you are creating.

To rename a file or directory, use the command move, What is it mv. To change the name of the data directory newly created to docs, run the command:

mv ~/data ~/docs

Similarly, use the mv c

To remove the folder ./docs, use the command rm. However, you couldn’t run the command

rm ~/docs

This is due to that the directory is a directory and we have to indicate to the command rm you will delete more than one file. Use the option r (for “recursive”):

Everything about Lubuntu.

Lubuntu is an official Ubuntu distribution, whose main objective is to create an operating system that uses a minimum of …
Read more

Share this Article
Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *