There are certain commands that users of GNU / Linux we should know for its condition to be very basic. In this post we will talk about some of them and how they work, all we need is a terminal 😀
Table of Contents
He kills donkeys.
I think the most important command that we should know is:
This will be the one that takes us out of our doubts and troubles many times. Its use is simple, the basic syntax is $ man command, example:
$ man man
$ man mkdir
I work with folders and directories.
To change directory through the terminal we use the command cd. Its operation is simple in the terminal:
$ cd : We go directly to our / home folder.
$ cd /home/elav/Documents/PDF/ : Let's go to the folder PDF within / home / elav / Documents.
$ cd .. : We go up one level. If we are within PDF we are going to / home / elav / Documents.
$ cd ../.. : We go up two levels. If we are within PDF we are going to / home / elav /.
If we want to see which folder we are in, we use the command:
To create a folder we use the mkdir command:
$ mkdir /home/elav/test : We create the test folder inside / home / elav.
$ mkdir -p /home/elav/test/test2 : We create the folder test2Within / home / elav / test /. In case the folder test does not exist, it is created.
There are several commands to view information on files or folders, and the space they occupy. The best known is ls, which helps us to list the content of a directory.
$ ls : List the contents of the directory
$ ls -l : List the contents of the directory as a list, plus it shows other data.
$ ls -la : List the contents of the directory, including hidden files (they have a period in front of the name)
We already saw the disk space and size commands in this post, so I don't put them.
I work with files.
There is a lot of fabric to cut here, but this time I'll talk about the commands cp (to copy), mv (to cut / move) and rm (Remove / Delete).
$ cp /home/elav/fichero1 /home/elav/fichero2 : We create a copy of the file1
$ cp /home/elav/fichero3 /home/elav/fichero2 : We copy and replace file3 en file2.
$ cp -R /home/elav /home/elav/bckup : We copy all the contents of the directory elav for / home / elav / backup. The -R (Recursive) has to be used for folders.
$ cp /home/elav/fichero* /home/elav/bckup : Copy everything in the name file, no matter what comes back, or the extent.
Something similar is the command mv, but in this case, the file1 will be moved (or renamed) in file2.
$ mv /home/elav/fichero1 /home/elav/fichero2
In the case of folders, it is not necessary to put the option -R.
$ mv /home/elav/bckup /home/elav/bckup2
And finally we have the command to delete files or directories.
$ rm /home/elav/fichero1 : Delete file1.
And in the case of folders, if we have to use the option -R.
$ rm -R /home/elav/bckup : Delete the folder back up.
To improve these commands, we can use the option -v (verb) that will show us on the screen the actions that the command is performing at that moment.
These are some very basic commands, but certainly worth knowing. Later we will show you others.