Hello Sunil
Linux Commands Cheatsheet

Linux Commands Cheatsheet: Basic Linux Commands

6# touch 

This command is used to create a file. For example, if we want to create a  text file then type touch demo.txt.

Linux-basic-command-touch-11

As we discussed earlier rm and  rm -r command in our previous section, let’s do some practice those commands here.

By using rm command you can delete demo.txt file as mentioned below:

Linux-basic-command-touch-12

But when you use rm -r command then it delete directory (India) and the files (demo.txt) it contains.

Linux-basic-command-touch-13

7# man 

To know more about a command and how to use it, then you can use man command. man stands for “manual” which is a reference book of a Linux operating system. It is similar to HELP file found in popular software.

For example, man ls shows the manual pages of the ls command.

Linux-basic-command-man-14

In addition to man command, use --help command with argument show the ways the command can be used. For example: ls --help.

Linux-basic-command-help-15

8# cp 

It stands for copy. This command copies file or group of files or directory from one location to the other. It takes two arguments: The first is the location of the file to be copied, the second is where to copy.

For example to copy democopy.txt file from Asia directory to Russia directory then you can follow the below instructions.

Linux-basic-command-cp-16

What we did here, we checked all of our directory with the help of ls command. Then to find the path of democopy.txt file from Asia and Russia we used pwd command.

Finally we used cp command to copy democopy.txt file from Asia directory to Russia.

9# mv 

It stands for move. This command is used to move one or more files or directories from one place to another through the command line. We can also use the mv command to rename a file or directories. Let’s do some practice.

Suppose you want to move a file democopy.txt from Asia directory to a new location /home/sunil/Russia, then execute the command as follows:

Linux-basic-command-mv-17

What we did here, we checked the path of Russia directory by using the command pwd. After checking the path we typed mv democopy.txt /home/sunil/Russia to move democopy.txt from Asia directory to Russia.

As discussed we can also use mv command for file renaming. Let’s change the file name of democopy.txt to newdemocopy.txt.

Linux-basic-command-mv-18

10# locate 

The locate command is used to locate a file by name in a Linux system which resembles search command in Windows. This command is useful when you do not know where a file is saved or the actual name of the file.

Let’s do some practice:

Linux-basic-command-locate-19

Here we tried to find a file by its name such as Asia. But if you want to ignore uppercase or lowercase case while typing a file name, then use -i argument.

So, if you want a file that has the word asia, it gives the list of all the files in your Linux system containing the word asia when you type in locate -i asia.

Also Read: What is difference between locate and mlocate

11# echo & cat 

The echo command is one of the most basic and frequently used commands in Linux. This command is commonly used in shell scripts to display a message or output the results of other commands.

For example, if you want to add some line of text to a file named newdemocopy.txt, you just need to type in, echo hello, I am Sunil >> newdemocopy.txt.

Linux-basic-command-echo-20

Use the cat command to display the contents of a file. The cat command is actually a concatenator but can be used to view the contents of a file too.

Linux-basic-command-cat-21

Sunil Pradhan

Hi there 👋 I am a front-end developer passionate about cutting-edge, semantic, pixel-perfect design. Writing helps me to understand things better.

Add comment

Stay Updated

Want to be notified when our article is published? Enter your email address below to be the first to know.

Sunil Pradhan

Hi there 👋 I am a front-end developer passionate about cutting-edge, semantic, pixel-perfect design. Writing helps me to understand things better.