Linux is a free and open-source operating system that has several distributions such as Debian, Ubuntu, Fedora, etc. Linux is free, efficient, and provides better security features.

This write-up will discuss in detail how to use basic commands in Linux.

There are two types of commands in Linux:

  • Basic Commands
  • Intermediate Commands

Let’s discuss them one by one in detail.

Basic Commands in Linux

Some of the basic commands in Linux are listed below:

Basic Command 1: pwd

The pwd command tells us about the directory we are present in. It provides us complete path to the directory which means the path that starts from the root. 

In our case, the user directory is /home/linuxuser.

Basic Command 2: ls

This command displays all the files in the directory that we are currently present in.

Basic Command 3: ls -a

This command prints all the hidden files in the system.

Basic Command 4: mkdir

To create a new folder or directory in the system, use the mkdir command. For instance,

Let’s create a folder named “Ubuntu1”. Type the mkdir command along with the folder name in the terminal as shown below:

To verify the creation of your folder, go to files and you will see the folder present there. 

Basic Command 5: rmdir

To delete a folder or directory, use the rmdir command.

Note: This command is only used to delete empty directories.

It can be seen that the folder is deleted successfully.

Basic Command 6: rm -r

This command is used to delete the folders and directories and all the files present within them.

For instance, let’s delete the uni_files folder in our system.

It can be seen that the folder is deleted successfully.

Basic Command 7: touch

To create an empty text file, the most commonly used command is the touch command. For instance, let’s create a new text file named new.txt.

By looking at the snapshot below, we can see that the new text file is created successfully.

Basic Command 8: man

This command tells us about the details of any command and how to use it as well.

For instance, let’s find out some details about the pwd command.

It can be seen that the details are displayed successfully.

Basic Command 9: mv

To rename a file through the command line, use the mv command.

For instance, let’s rename a file new.txt to file1.txt.

It can be seen that the file name is changed successfully.

Basic Command 10: locate

To locate or find any file in a Linux system, use the locate command. When you are unsure of the location or name of a file, this command can be helpful.

For instance, let’s locate our newly created file.txt in our Linux system

It can be seen that the path of the file is displayed successfully.

Intermediate Commands

Some of the intermediate commands in Linux are listed below:

Intermediate Command 1: echo

The echo command is used to move data, usually text into a file. It can also be used to create a new file.

For example, let’s move some data into a file.

It can be seen that the text “Welcome to Ubuntu” is successfully added to the new.txt file. 

Intermediate Command 2: cat

This command prints the contents of a file.

For example, let’s see the contents inside a file in our Linux system.

It can be seen that the content inside the new.txt file is displayed successfully.

Intermediate Command 3: nano

nano is a text editor that comes pre-installed in many linux distros. It can recognize most of the languages and denotes keywords with colors. It can be used to create and modify files.

For instance, let’s create a file named Ubuntu1 using nano editor.

Press CTRL+S to save the file. CTRL+X to leave the editor.

Intermediate Command 4: sudo

Sudo means “SuperUser Do”. sudo command performs administrative and root privileges.

For instance, let’s change the password of our Linux system using sudo.

It can be seen that the password is updated successfully.

Intermediate Command 5: df

This command is used to display the available disk space in each of the partitions in your system. Use the df -m command to display it in megabytes.

It can be seen that the available disk on our system is displayed successfully.

Intermediate Command 6: du

This command tells us about the disk usage in a specific directory.

For instance, let’s see the disk usage in our Downloads folder.

The disk usage is displayed successfully.

Intermediate Command 7: zip and unzip

Use the zip command to zip a file or multiple files in your system. Unzip is used to extract the zipped archive.

Let’s zip some files in our Linux system.

Now to extract these zip files, use the unzip command

It can be seen that the zip files are extracted successfully.

Intermediate Command 8: uname

This command displays information about the linux distro, your system is running on. uname -a command prints most of the information about the system.

The information is displayed successfully.

Intermediate Command 9: hostname

This command prints your name in the host or network. hostname -i displays the IP address of the network.

The hostname and IP address are printed successfully.

Intermediate Command 10: apt-get

Use the apt-get command to install packages in your Linux system.

For instance, let’s install a new text editor jed using apt-get

The text editor has been installed successfully.

Conclusion

There are two types of commands in Linux, the basic commands and the intermediate commands. Some of the basic commands are pwd and ls. The pwd command tells us about the directory we are present in whereas the ls command displays all the files in the directory that we are currently present in. Some of the intermediate commands are echo and cat. The echo command is used to move data, usually text into a file. It can also be used to create a new file whereas the cat command prints the contents of a file. This blog post illustrated how to use basic commands in Linux.