
We have already seen what Linux / Unix is and how to install one of its most popular distributions (Ubuntu) so from now on we will go into the matter regarding what you can do with Linux using the command line, we will see hundreds (if not all) of commands with their respective options, we will discover shortcuts to fulfill certain functions and learn to create scripts. Finally, at the end of this new series of tutorials we should be able to use the command line decently and be prepared to make advanced configurations of our system.
In this series of tutorials the images will come from my virtual machine, which has Ubuntu installed but essentially all the commands and techniques that we will see here will be transportable to Mac OS, Unix or any other Linux distribution.
Let's start at the beginning Where is the command line?
Ok, this may vary depending on the operating system, you will usually be looking for a program called “Terminal” which is in Applications -> Utilities if you are on a Mac, in some Linux distributions it is in Applications -> System or Applications -> Utilities .
In my version of Ubuntu is in Computer -> usr -> share -> applications but, since Ubuntu has a side “Dock”, I dragged it towards it from the corresponding folder.
In other Linux distributions you can also access the command line by right clicking on the desktop and choosing the option “Open a Terminal”.
We mentioned earlier that the software responsible for interpreting and executing all commands is called "shell". There are several types of "shell" but the most common is the bash (Bourne again shell) and is the one that most Linux distributions include by default. To know which version of the shell you are using you can execute the following command in the terminal:
echo $ SHELL
Which should give you the location and name of your shell, these tutorials will use the "bash".
Shortcut:
The terminals save the history of the executed commands, therefore, if you want to re-execute a command you can press up until you reach the command you are looking for and you can even edit it by moving the cursor from left to right.
Navigating the command line
We will start with the most basic of the commands.
pwd
The pwd command is an abbreviation of the phrase "print working directory" which tells the shell that it must print on the console the absolute path on which you are currently working.
The term "absolute path" refers to the exact address in the system to which reference is made, starting from the root to the sheet that you really want to access and always starts with the bar ( / ). Additionally, the route can be "relative" which, as the name implies, refers to the route from the current location to that sheet and does not use the bar ( / ) at the beginning.
The reason why I speak of “root” and “leaf” is because the file structure of the system (of all OS) is hierarchical in the form of a tree that can be seen represented as follows:
In this way, if you would like to continue browsing down the tree you should know what leaves (or branches) exist in the directory in which you are located, for this we use the next command.
ls [options] [location]
Another basic command that lists the files and directories located in the target folder. What is in square brackets is optional and allows us to modify the way in which the results are displayed and the folder we want to review.
In this case we can see how it works more or less. The first command shows a simple list of those directories and files in the current directory. The second one lists them using the “-l” option, which is a long list and shows the permissions on the object, the number of blocks, the owner of the same, the group to which it belongs, the space it occupies, the date and time of modification and, finally, the name of the file or directory. And the third one lists the files and directories in the "Documents" folder.
Note:$config[ads_text5] not found
There are other additional options that can be added, among them is “-a” that shows the files and documents including those that are hidden.
Finally, to navigate to a directory, we use the following command.
cd [location]
Abbreviating "Change Directory", this command moves the prompt to the specified path, either absolutely or relative. If no route is specified, it will take you directly to the "home" directory (which in the case of my user "manuel" is / home / manuel).
This is all for now, we will continue with more commands in the next tutorial. I await your comments, until next time!
- 0
Articles