Most Useful Linux Commands

In this article, you will learn about the most useful Linux commands.

When we talk about Linux commands we understand it is complicated and not easy to use. But when we will be familiar with commands then you find that it will always save your time and you can use only typing the command on the terminal. So you do not need to click many times to just find or copy or create a new file.

pwd command

If you want to know the exact location means the current working directory, In which folder you are now then you can use this command.

So you have to type pwd and it will return you to an absolute path. The absolute path is also known as the full path of that directory or folder. It always starts with a forward-slash (/).

For example, /root.

Also, read more about the pwd command

Or you can watch the video for the pwd command.

pwd command in Linux | Watch the pwd command in the video.

ls command is the most useful Linux commands

The ls command is the popular command. It helps us to view the content of the current working directory (Folder). But if you want to see the content of the other directories then you have to type the pwd and absolute path of that directory.

For example,

ls /var

Also, read more about the ls command

ls command in Linux | Watch the ls command in the video.

cd command

cd stands for change directory. If you want to move from one directory to another directory then you can use the cd command. Also, it is another popular command in Linux and Unix-like systems.

For example

If you are in the /root directory and you want to go to the /var directory then you can simply type the command below.

cd /var

Also, you may find a few examples useful

To move one directory up then you can use two dots after typing cd like as

cd ..

If you want to go to the home directory then you can only type cd

cd

But if you want to go to the previous directory then you type (Hyphen) along with the cd command, for instance.

cd -

Also, you can read more about the cd command

Or you can watch the video for the cd command.

cd command in Linux | Watch the cd command in the video.

mkdir command is the most useful Linux commands

Sometimes you want to create a new folder or directory using the command on the terminal then you can use the mkdir command. It will create a new directory. For example, if you want to create a folder in /root then you can type the mkdir command and then the full path where you want to create the folder like as below.

mkdir /root

Also, you can read more about the mkdir command

Or you can watch the video for the mkdir command.

mkdir command in Linux | Watch the mkdir command in the video.

rmdir command

If you want to delete any directory then you can use this command. Also, you can use the only rm to delete the folder or you can use some option along with the rm command.

Also, you can read more about the rmdir command

Or you can watch the video for the rmdir command.

rmdir command in Linux | Watch the rmdir command in the video.

cp command is the most useful Linux commands

It is the most useful Linux command. The cp command helps us to copy any file or directory from one folder to another. This command is very useful for copying files or directories.

Also, you can read more about the cp command

mv command is the most useful Linux commands

The main use of the mv command is moving the files or directories from one location to another location. But we also use it to rename the file or directory name.
To move any file or directory, you have to type the source location and then the destination location. For example, if a file name file.txt which is located in /tmp and you want to move it in /opt then you can type like as

mv /tmp/file.txt /opt

Also, you can read more about the mv command

touch command

you can use the touch command to create a blank new file using the terminal. For example, you can create a file with the name of routineCheck in /tmp then the command will be as below.

touch /tmp/routineCheck.txt

Also, you can read more about the touch command

cat command

There are many uses of the cat command. So you can use it to view the file content on the terminal, create new files, and redirect the output to another command-line tool or file.

Also, you can read more about cat command

head command

If you want to see the first line of any text file or piped data directly from the terminal then you can use this command. By default, It shows the first ten lines, but you can change this number. For example, if you want to show the 3 lines then you can type the file name and its extension. So the command will be as below.

head -n 3 filename.ext

Note: Here .ext stands for extension, it may be .txt.

tail command is the most useful Linux commands

It has the same function as the head command. But it shows the last ten lines instead of the first ten lines. For example, if you want to view the last 5 lines then you can use the command below.

tail -n 5 filename.ext

Note: Here .ext stands for extension, it may be .txt.

diff command

diff stands for the difference. So this command helps us to compare the contents of two files line by line. After checking the files, it will output the lines that do not match. This command is very useful for the programs to make alterations instead of rewriting the entire source code. For example,

diff file1.ext file2.ext

locate command

If you want to find a file then you can use the locate command. This command is similar to the search command in Windows. The file name is case sensitive so if you want to search a file without uppercase or lowercase difference then you can use the -i argument along with locate command.

For example, if you are looking for a file name that contains the word Linux Gurus but you do not remember the exact word then you can search

locate -i linux*gurus

find command

You can search for files and directories using the find command. It is the same as locate command but there is one difference that is you can search files within a given directory using the find command.

For example,

find /home/ -name findfile.txt

Note: the above command will search for the file findfile.txt within the home directory and its subdirectories.

grep command is the most useful Linux command

grep command helps to find all the text in a given file.

For example,

grep him findme.txt

In the above command, it will find all the words him in the findme.txt. Full lines will be displayed which contain the searched word.

sudo command

sudo stands for Super User Do. This command enables you to run the task with administrative or root permission.

lsblk

lsblk command helps you to find the available block devices of your Linux system. It represents block devices in a tree structure.

df command

df command is another Linux command. It prints essential information about the disk space usage on the terminal in percentage and KBs. But in case, you want to see the report in megabytes then you have to type

df -m

the du command

Sometimes, you want to check how much space a file or a directory takes then you can use the du command.

The report you will see will be printed in block numbers. But if you want to see in bytes, kilobytes, or megabytes then you have to add -h argument to the command line. For example.

du -h

chmod command is the most useful Linux commands

The chmod command is a command that is useful to change the read, write, and execute permissions of files and directories.

If you want to read more about permission then you go to the https://www.linuxgurus.in/linux-file-permissions/

chown command

chown command is useful to change the ownership of a file or a directory to the specified user.

If you want to read more about permission then you go to the https://www.linuxgurus.in/linux-file-permissions/

jobs command

If you want to see the current jobs along with their statuses then you can use the jobs command.

Conclusion

In this tutorial, you learned about the most useful Linux commands. I will keep updating important basic commands.

Most Useful Linux Commands | Linux Commands | Unix Commands | Basic Linux Commands | Linux Server Commands | Best Linux Commands | Very Important Linux COmmands | RedHat Linux Commands | CentOS Commands | Rocky Linux Commands | Debian Most Useful Linux Commands |

Also Read About:

most useful linux commands for developers

most useful linux commands pdf

all linux commands

top 50 linux commands

linux commands cheat sheet pdf

Leave a Reply