New to Linux? We give you several useful commands for the terminal

basic linux terminal commands

Advanced users or those who have been using Linux on a regular basis for some time have long realized the infinite possibilities offered by text mode, that part of the interface in which we can only interact with the computer using the keyboard and that, if we do not know the appropriate commands, we cannot use it reliably.

With the Linux terminal we can do simple queries to the system to show files, help manuals or create a file; to even configure a XAMPP server, query a database, and all kinds of administrative tasks. However, to get there there is still a lot, so we are going to show you some basic commands you should know if you just got to linux.

Comparisons are hateful and I don't want to turn this article into a "Linux versus Windows", but Microsoft's operating system can serve as an example to illustrate some of the cases that we are going to deal with in the following lines. It is clear, I insist, that this is only an illustrative example.

Before continuing, it is worth making it clear that to use these commands no need to have administrator privileges. The different sections

pwd

Unlike Windows, where if we go to the command prompt we do have a clear indication of where we are -for example C:Windows>-, on Linux we will not always have this information at a glance. This implies that if we are working with different directories or in subdirectories quite buried in the system we can easily get lost. By typing this command we will know exactly where we are.

$ pwd
/home/tu-usuario

cat

This command will show us the content of a file, whatever it is. This implies that if we ask to see a text file the terminal will return what has been written in it, while if we execute any other file we could obtain unreadable machine code or MD5 checksum of file integrity.

It can be used with modifiers so that a long text file can be read in a paginated way, but about modifiers and how to know them we will talk a bit later.

$ cat hola.txt
¡Hola!

ls

ls does the same functions as dir in MS-DOS, but in a slightly different way. We can also use the MS-DOS command in Linux, of course, but its performance, although comparable, falls short. Thanks to the color code of the terminal, with ls we can distinguish if what it shows us are files, folders, scripts or any other thing.

If together with ls We use modifiers we can see all the directories of the path in which we are in the form of a list, paged, showing all the files and subdirectories and even the permissions they have granted. Again, we'll talk about modifiers later.

$ ls
Documentos Descargas Escritorio Imágenes Música Podcasts Plantillas Público Vídeos

cd

If you've ever used the command prompt or Windows console and you have moved through the directory tree, then you know what this is for. In any case, it is convenient to clarify for those who do not know that the command cd allows us navigate the unit in which we are, changing to specific locations regardless of which is ours at that time.

$ cd /home/usuario/Documentos/Ejercicios

$ cd /home

To go up the directory tree through the terminal we will have to use the command cd ...

touch and rm

The first command is used to create empty file through the terminal. If the file we created already existed, then it will update the modification time.

$ touch texto.txt

As for the rm, what it allows us to do is delete any file.

$ rm texto.txt

mkdir and rmdir

In the particular case of these two terminal commands, which go almost together, they allow us create and delete an empty directory respectively.

$ mkdir /prueba

$ rmdir /prueba

cp and mv

The command cp It serves for copy a file or directory from an original location to another destination. Using cp it is very easy to have a backup file copied to another location. For example, suppose we have a file on the drive and we want to move it to a removable device:

$ cp /home/usuario/Documentos/Ejercicios/Ejercicios.txt /media/usuario/pendrive/Ejercicios.txt

As for the mv, is equated with the "Cut" function of Windows. That is to say, grabs a file from its original location and moves it elsewhere, removing the file from the first location. Following the thread of the previous example, suppose we want to move a file from the drive to a removable device, so that we have it only there:

$ mv /home/usuario/Documentos/Ejercicios/Ejercicios.txt /media/usuario/pendrive/Ejercicios.txt

Mon

The command man refers to the complete manuals of the commands we have been using so far. This manual will not only describe the correct use and syntax for each of these commands, but also - this time it will - allow us to know what modifiers we can use with them. In this way, for example, we look for the manual page of the command ls:

man ls

We should see something similar to this:

linux manual page

If we scroll through the different pages of the manual with the keyboard cursor we will see little by little the different modifiers we can use with the instruction so that it is much more complete. For example, if we add the modifier -l a lsWhat we will see is a detailed list of directories in the location where we are, in addition to the permissions granted to each element:

$ ls -l
total 48
drwxr-xr-x 3 usuario usuario 4096 mar 1 19:26 Descargas
drwxr-xr-x 2 usuario usuario 4096 mar 1 18:06 Documentos
drwxr-xr-x 2 usuario usuario 4096 mar 1 20:16 Escritorio
drwxr-xr-x 2 usuario usuario 4096 mar 2 07:38 Imágenes
drwxr-xr-x 3 usuario usuario 4096 feb 27 12:09 Música
drwxr-xr-x 2 usuario usuario 4096 feb 6 09:58 Plantillas
drwxr-xr-x 2 usuario usuario 4096 feb 6 09:58 Vídeos

And so far a brief, but extensive review, reviewing some basic terminal commands that you should know if you just got to Linux. It may seem a bit cumbersome at first, but the terminal is an extremely powerful tool that you should never stop using under any circumstances. Dare to give it a try and you will discover that for precision tasks there is nothing better than doing it yourself by hand.


Leave a Comment

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

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.