With the terminal: Basic commands in GNU / Linux

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 😀

He kills donkeys.

I think the most important command that we should know is:

$ man

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:

$ pwd

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.

Information commands.

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.


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.

  1.   Courage said

    And killall?

  2.   oleksis said

    It would be appreciated if these good basic and important post for beginners could be attached a version of it in pdf or install a WordPress plugin that exports the input to PDF.

    Regards!

    1.    KZKG ^ Gaara <° Linux said

      Some time ago (several months now, almost 1 year) I reviewed plugins that export to PDF but none ended up convincing me, I will look for one that is good enough to install it here 😀

      Greetings partner

      1.    Courage said

        What if you program it?

  3.   mitcoes said

    There are some cheat sheets, which can even be used as wallpaper, I even saw an application / cheat sheet that was added to the terminal, but almost all of them are in English.

    Perhaps an adaptation to Spanish of them would help potential readers of this interesting series of introductory articles to the console.

    In his day 1991 I bought Anaya's book and recently I reread it and I remembered the song how much we have changed, dear Linux.

    1.    KZKG ^ Gaara <° Linux said

      If you find these chops, leave us the link and I myself will gladly make the necessary translation 😉
      regards

      1.    Courage said

        There is something similar:

        http://sinwindows.wordpress.com/2011/03/25/cheat-cube-para-varias-distros-de-linux-bonus-track/

        What I don't know is if you can see it, if you don't get them down and I'll send them to you

  4.   Andrew said

    The test command is also interesting 🙂

    test command