Skip to content

AskAndroids.com

Android Tutorial Station

Basic commands of the Linux terminal

There are already several articles in which we talk about the Linux terminal or console and it is time to show what I think are the basic commands of the Linux terminal .

This Linux terminal also receives the name of shell, Linux console or command line , any of these names is valid.

We already had several articles with tutorials that used the Linux shell, for example, how to install WordPress from the SSH console and we even talked about the most common program to access the terminal of a remote server, which is none other than PuTTY . All this has been more than enough reasons to dedicate an article to the basic commands of the Linux console .

Basic commands of the Linux terminal

To explain the different commands of the Linux console, an entire book could be dedicated and in fact there are already several. Our goal is not to deepen the use of the console, but to show those commands that we use more frequently and that will allow us to perform the basic tasks on our server , that’s why an article is enough for us.

pwd

It is one of the simplest commands and when used it shows us the directory in which we are located or also called the working directory. The letters pwd come from the English “print working directory” which describes the functionality of the command that is none other than “print the working directory”.

The simplest use example is: pwd

cat

Despite its name, it has nothing to do with cats, but what it does allow us is to print the contents of a file on the screen. It has to be clear that it only allows viewing contents.

An example of simple use is: cat lista.txt

ls

It is a command that allows us to list the contents of a folder or directory and files. The most basic use example is: ls /home/carpeta

This command accepts a series of parameters to show us more or less data about the contents of the folder that it lists. The one that will be most useful to you is when it is used with the “a” parameters to show hidden files and the “l” parameter to show the permissions, users and groups of the files and date.

To use it would be something like: ls -la /home/carpeta

CD

It is a very basic command and already present in the Windows shell and even the old MS-Dos. What allows us is to change the directory or folder as its name implies, since cd are the initials of “change directory” which translated is “change of directory.”

Let’s imagine that we access the Linux shell through PuTTY and after authenticating ourselves, the first command we use is pwd and it shows us /root as a working directory but it turns out that we want to change to the /home/monitor , then we execute the command: cd /home/monitor

To work with a directory it is good to know the reserved word ../

First of all ../ indicates that we lower a level in the directory, for example if we are in /home/monitor and run cd ../ will take us to the /home folder

You can use the reserved word several times and thus lower more than one level, for example if we are in the folder /home/monitor/www and execute the command cd ../../ will take us to the folder /home

mkdir

Create a folder or directory. Keep in mind that mkdir unless we specify otherwise create the folder in the working folder, for example if we are in /home/monitor and running mkdir portable will create the folder /home/monitor/portable

Sometimes we need to create several levels of the directory tree and it is not necessary to create each level with mkdir independently, we can create them all with a single mkdir command using the “p” modifier, for example: mkdir -p /home/monitor/manuel/programa/librerias/

touch

This command has a double function. If it is used on a file, its creation date is changed. If it is used on a file that does not exist then it will create an empty file with that name.

The most basic use example is: touch /home/monitor/lista.txt

In this case, if the monitor folder does not contain a list.txt file, it will create a file with that name and completely empty.

cp

It is a command that is used to copy files or folders from one site to another.

The most basic use example is: cp /home/monitor/lista.txt /root/lista.txt
The previous command would make a copy of the list.txt file in the /root folder

When using it to copy folders, it is important to use the “r” parameter that copies the contents of the folder recursively, that is, it will copy all the files and folders contained in the specified directory.

For example cp -r /home/monitor/ /root/backup_monitor/
The above command will copy the monitor folder and all its contents (folders and files) to the /root/backup_monitor/

mv

It works just like the cp command but in this case mv only moves the site files. The most basic use example is: mv /home/monitor/lista.txt /root/lista.txt

This command also mv lista.txt listado.txt us to rename a file, for example: mv lista.txt listado.txt

rm

This command allows us to delete files or folders. The most basic use example is: rm lista.txt

It can be used with the “r” modifier that recursively removes and the “f” modifier so that it does not ask for confirmation. For example rm -rf /home/monitor

The previous command would delete the monitor folder and all files and folders without asking us for confirmation. This command must be executed with caution.

man

This is the command that will help us learn more about these commands presented here and many others as it is the way to get help in the Linux shell. For example, if we execute man pwd will show us the help page of the pwd command (to exit the help page, press the q key).
Feel free to use man with other commands to see his help page and learn more about these Linux commands.

Here we end with the basic commands that will allow us to move through the different folders and perform the most common basic tasks through the Linux console.

At first it may seem complicated to use the shell but once you know the potential of each command well, you fall in love with the Linux console since it is a very powerful tool.

No comments yet.

Leave a Reply

Your email address will not be published.

Comments (0)