Skip to content

List of the main commands in Linux - learn how to use them

If you are a beginner in the Linux universe, you may have heard of the list of the main Linux commands, with some somewhat “scary” names, at first, and somewhat specific functions.

But the truth is that these Linux commands are not that difficult to learn and put into practice - you just need objective and direct content to help you better understand all the commands.

Thinking of helping you, the Linux Certification team developed this complete article, with everything you need to know about the main Linux commands and how to use them. Just read to the end. Follow up!

How to use the main Linux commands:

Before starting to use the main Linux commands, it is necessary to understand how to use them and how they actually work. After all, it’s impossible to apply something you don’t even know the purpose of, don’t you think?

So, know that Linux commands are mostly in text format, entered in an operating system reading terminal.

By entering the right commands, specific to each function, actions can be performed automatically, facilitating the work of those who use Linux in their daily lives.

Nano control

The first command to be learned by beginners in the Linux universe is the nano command. This command is very similar to Notepad, present in the Windows operating system, but is intended exclusively for the Linux terminal, where all commands are triggered.

The nano works as a “mini” text editor, with specific functions within it. With it, it is possible to open and read files, such as texts, to verify the spelling of the piece, cut and paste excerpts, search for specific terms and other secondary functions.

Each of these subcommands is activated by selecting the control key (“ctrl”) and the letter that represents the desired function.

The nano command itself displays a panel with the letters and their corresponding actions, so that the user simply selects. The combinations are:

  • Control and X: press to exit editing. As with other text editors, nano will ask if you want to save the file or not;
  • Control and G: opens a help screen for nano itself and the list of commands;
  • Control and O: used to write to the file;
  • Control and J: has the function to justify the text;
  • Control and R: read a different file, allowing you to add text fragments from it to your main file, which is open in nano;
  • Control and W: find a term within the text;
  • Control and K: responsible for cut the text;
  • Control and U: paste the cut text;
  • Control and C: Shows the current cursor position.
  • Control and T: check the spelling of the entire text;
  • Control and S: responsible for saving the file;
  • Control and A: directing the mouse pointer to the beginning of the line;
  • Control and E: direct the mouse pointer to the end of line;

In short, the nano command in Linux has the function of editing text files through the terminal.

Watch command

Simply put, the watch command repeats the execution of another command periodically. With it, you don’t have to execute these commands manually from time to time.

The watch command also features letters with subcommands to configure the desired repetition structure. The main ones are:

  • -d, which informs what changed with each update;
  • -n X, responsible for setting the repetition interval in X seconds;
  • -t; which disables the header;
  • -g; whose function is to finish executing if the command output changes.

Script command

This is responsible for routing or creating a structure for executing commands entered in the Linux shell, with the possibility of entering a time interval between executions or not.

Thus, the script command can be a “hand in the wheel” for those who need to document and record the entire process of installing a software or application, so that later it is possible to verify the path followed.

To create and start it, simply execute this path:

  • $ script arquivo.log

Cd command

The cd command in Linux has a very simple function: to show or change the directory where a file is located. With it, the opposite can also be done: enter the path of a file and open it.

To do this, simply enter:

  • cd images/ (if you have a folder with that name on your computer, it will enter it);
  • to access a file inside that folder, simply add cd images/subfolder/filename (so you can access the file inside the images folder);

ls command

On the other hand, the ls command is responsible for listing existing files, filtering the search result by the initial letter or character of the files.

This feature is interesting because it clearly shows all the files on your computer.

It is also possible to add other filters to the search, such as separating by commas, showing by columns, and even differentiating files by color.

Some commands are:

  • —color=auto, which separates files by color;
  • -a, —all, which presents all files, even those hidden;
  • -A, —almost-all, which presents almost all files, except the entries “.” and “..”
  • -m, which makes a list of all the files separated by a comma.

rm command

The rm command is responsible for removing files and directories, according to your permission as a user. To do this, there are the subcommands:

  • -f, which removes files without questioning the user;
  • -r, -R, which removes both the directory and its content;
  • -i, which requests the user’s authorization before removing;
  • -d, —dir, responsible for removing empty directories;

Find command

To find files, simply use the find command. When executing it, you must indicate the starting location of your search, that is, from where you want the command to start running.

The search base syntax is as follows:

  • find [path] [expression]

Grep command

The grep command on Linux is responsible for searching for words or terms within all text-formatted files of the system, in order to present the content sought.

To activate it, you need to use the syntax:

  • grep [options] regex [files];
  • or: command | grep [options] regex.

“Options” are the filters you want to add to the command for a more selective search, while “files” are the names of the files you want to find.

chmod command

Finally, the chmod command can change all user accesses to alter and view system files.

There is a hierarchy between those who create the file, those who have access to edit, and those who can only view without changing anything. Within this command, there are several sub-commands that change these settings, such as:

  • Chmod 644;
  • Chmod 755;
  • and Chmod 555.

Each of them can be applied in practice to change user access to certain system files.

Deepen your Linux knowledge with our online course! Enroll now!

Conclusion

principais comandos linux práticosPhoto: Freepik | Main Linux commands that make everyday life easier. Despite having several technical terms and execution syntaxes, the main Linux commands are simple to understand and learn - even more so to execute.

To succeed in the Linux universe, the secret lies in having access to good content with a good teacher.

That’s what happens here in the Linux Certification: we have several courses rich in content for different learning levels and objectives, all taught by Professor Uira Ribeiro, who has over 23 years of experience career. It’s worth checking it out!