The 10 most used commands in Linux

The Linux terminal is where you execute the commands with which you can interact with the system. These commands are many, but there are always some that are used more than others. Today, you will know the 10 most used commands on Linux.

A command is an order that you enter into a terminal to get a thoughtful response from the system. Each command has its options that modify the behavior of the command. In addition to this, they also have a help section to learn more about it.

Some commands can be passed an argument or parameter, which is an input that we give to a command so that it can be executed correctly. In most cases, the argument can be a file path, but it can be anything you type into the terminal.

For everyone, mastering the Linux command line is a great help to do a more agile and independent job when working in Linux/Unix development environments.

10 Most used commands on Linux

Before we start, it is necessary to clarify that each person who uses Linux will have his list of most used commands. A developer will probably use some commands more frequently than a sysadmin, and a sysadmin will most likely use some commands more frequently than a novice user.

The main idea is to locate those commands that are most frequently used and that can serve almost any user and purpose.

1.- ls command

The ls command is one of the easiest and most common commands to use on Linux. This command displays the contents of a folder. For example, if the prompt is located in the HOME directory, then the contents of this directory will be displayed.

ls

You can also specify a directory to display

ls ~/Documents

The displayed output will indicate all items that are in the folder.

With some options, you can modify the behavior of ls for example, adding the -a option will show all files and folders including the hidden ones

ls -a

Meanwhile, with the -l option it will be shown as a list including the permissions that it has

ls -l

As you can see, it is easy to use and is one of the most common commands you can find.

2.- The cd command

The main purpose of the cd command is to change directories. Generally when you open a program it will be located in the user’s HOME directory, so if you need to work in another one, then you would have to change it.

An example of using the cd command is as follows

cd [directory]

For example:

cd ~/Documents

Replace [directory] with the name of the directory at the prompt, but you can also specify the full path.

cd /usr/bin

You can use it to move up one level of directory hierarchy

cd ..

Or access the HOME folder directly

cd ~

The cd command is one of the simplest you can find, but also one of the most useful and used for what it gives us.

3.- The rm command

rm provides the functionality to delete files using the terminal. Although we can always do it using a graphical interface, the truth is that rm is very fast in its operation.

To delete a file, you can run

rm [file]

This [file] can be the name along with the file extension.

For example,

rm example.txt

You can also delete several files at once

rm example.txt file1.jpg

Or use absolute paths

rm /home/user/Downloads/file.mp4

rmis also used to delete directories, but for that, you have to add the-r` option and specifying the directory

rm -r folder/

4.- The mv command

The mv command is used for two things. The first is to move a given file to another directory.

An example of this is

mv [file] [new-location]

For example,

mv file.txt ~/Documents

In this case, the file file.txt is moved to the /home/user/Documents folder.

The second way the mv command is used is to rename a specific file.

For example,

mv file.txt file1.txt

This way, the file file.txt is renamed to file1.txt.

It is that quick and easy.

5.- The mkdir command

mkdir is another widely used command from the terminal that simply creates a new folder or directory.

An example of how to use it could be

mkdir newfolder

This will create a folder called newfolder at the current address prompt. You can also do this by specifying an absolute path.

mkdir /home/user/newfolder

In case the path does not exist, you can create it with the -p option

mkdir -p ~/newfolder/folder/folder/folder2

In case the path does not exist, the corresponding folders will be created.

6.- The touch command

Although the touch command has several functions, we usually use it to create empty text files. This is interesting because in many situations it can be of great help.

In this way, you can create an empty text file with touch.

touch file.txt

This will create this empty file. You can also specify the absolute path to it.

touch /home/user/folder/file.txt

This will create the file in the corresponding path.

This command is one of the most important commands on Linux and is very common among developers.

7.- The clear command

This is perhaps one of the easiest, but believe me if you work with the terminal you will use it a lot. The clear command just clears the terminal screen so that we have a more focused view of what we want.

If other commands provide on-screen output, and it is no longer useful, you can clear the screen.

clear

In this way, the command is used, and the screen is cleared.

8.- The cat command

Another command widely used on Linux is the cat command. This command is mainly used to display the contents of a text file. It can also be used to view several files at once.

The most basic way to use the command is as follows

cat file.txt

This way in the same terminal you will have as output on the screen the content of this file. In the same way, you can work with absolute paths.

cat /home/user/Documents/file.txt

And with several files at the same time

cat file1.txt file2.txt

9.- The kill command

The kill command oversees closing an unresponsive process in the system. This is important to know in case we want to apply it in some opportunity.

To achieve this, just follow this command syntax

kill [options] [pid] command

The options of the kill command vary depending on the kill signal you would like to send. One of the most commonly used is -9 and the PID is the process identifier.

An example of how to use it could be

kill -9 2536

Where 2536 is a PID I made up. Generally, there will be no output on the screen, but the process that may be associated with a program will no longer exist.

10.- The sudo command

The sudo command is a command associated with the command prompt of the same name that gives a particular user root permissions. Of course, sudo can be configured so that only the desired users can use it without problems.

To use it, just install it and from the root user add the user to the allowed list.

Then you can use it

sudo [command]

An example

sudo mkdir /opt/folder

This way as root user we will be able to create that folder in the required location.

Bonus

If you want more information about each command you can use the man command or visit this link where you can consult these commands,

Conclusion

There are many Linux commands that you can know and use; however, it is useful to know the most important and most used ones. Of course, many users will use different commands, but this is the general idea.

I hope you liked this post and help us to grow by sharing it with all your friends. So, these was the 10 most used commands in Linux.

Share This:

Leave a Comment

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