Mastering the Terminal
A Historical Tool
Nowadays, very few computer specialists still use the terminal. It must be said that the use of graphical user interfaces makes it possible to perform most tasks simply and quickly. After all, what could be more natural than clicking on the "New Folder" icon when you want to create a new folder ?
However, this simplicity of use has not always existed. When the first computers came out on the market, they did not yet have graphical user interfaces. You had to use the terminal to make a simple file move. This characteristic slowed down the adoption of computers by the general public, who saw them as reserved for the elite.
In order to perform any action on your computer, you had to know the name of the corresponding function, how to use it, and its possible parameters. Not only did you have to have the list of these functions in mind, but you also had to be at ease with computers, at the risk of deleting the wrong file… Whereas nowadays, all you have to do is simply move the file in question with the mouse, which then activates various commands performing this action behind the scenes.
But despite all the qualities of the graphical interfaces, the terminal has some advantages that make it still in use today. The most common example is server administration.
You may have already heard of datacenters, those large centers that allow servers to run continuously, so you can access your favorite website at any time of the day. To achieve this, each of the screens available allows you to administer several servers at once, using only the terminal.
The explanation is simple : Not only is a server using only the terminal more powerful, (Because it doesn't have to take care of all the graphic resources) but it is also faster to handle, as long as you know how to use a terminal efficiently.
You don't believe me ? Then I propose you a small demonstration… If you need to create about ten folders manually, you will need to right-click ten times, and click ten times on the "New folder" button. Using the terminal, you just need to copy the command to create a folder :
Then you just have to paste this command ten times into the terminal, and you'll have your ten folders. Of course, this requires you to be comfortable with the terminal. If you have to do a search to find the name of the command, you won't save time… But by dint of using the terminal, you will know the commands by heart, and thus save precious time !
Of course, this advantage is especially valid for professionals who handle a lot of data all day long. A private individual would have no interest in using the terminal, and will prefer to use a graphical user interface, for the sake of simplicity.
Moreover, I talked about server administration, but the terminal is also an important tool for developers. If you do back-end programming, (On servers) you will encounter many cases where the use of the terminal is mandatory. A good example is the Composer dependency manager, which allows you to manage the dependencies of your projects. If you need to use it to create a project depending on a framework, such as Symfony, you will have to initialize it like this :
compose create-project symfony/website-skeleton project-name
This is an essential step, because Composer is a tool that can only be used on the command line, and does not have a graphical user interface.
Finally, some passionate people like me, learn how to use the terminal for another reason : To discover how computers work, and to satisfy their passion. It's also a good reason, and maybe even for you.
One Terminal, more Terminals
As explained previously, the terminal will send instructions to your operating system to perform the requested action. (Create a folder, move it, …) Unfortunately for us, just as there is not a single operating system, there is not only one terminal…
To be precise, we can distinguish two main families of terminals.
• The first one is based on MS-DOS, and runs under Windows.
• The second one is Unix-based, and runs on MacOS and Linux.
Fortunately, most commands have an equivalent on the complementary operating system, and only the name and parameters used change. Let's take the command to list the folders in the current directory. To use it, we will call :
• dir in Windows.
• ls under MacOS or Linux.
Which both proceed in the same way.
Most commands take additional parameters. These tell the function what to do, and how to do it. If you want to create a file under Unix, you will have to use :
Here, file-name is a parameter of the touch function, and corresponds to the folder to be created. If we want to create a hello-world.txt file, we will have to execute the following command :
There are of course many parameters, depending on the function used.
However, I recommend that you be careful with the commands you are going to use. In this article, we have only created files. The worst thing that can happen with this command is to create a folder with the wrong name… But if you use a command to delete a folder, and you get the name of the folder you want to delete wrong… You will have definitely lost an important folder. It may seem obvious when you say it like that, but remember that the terminal is much less instinctive than a graphical user interface..
If you try to delete an important folder with a graphical user interface, such as the System32 folder on Windows, (Equivalent to the /System folder on MacOS, or /bin on Linux) you will get a window that will open forbid you to delete this folder. But if you do the same thing with the terminal, you will get a simple warning that, once bypassed, will permanently delete the file, no matter how important it is !
Finally, I must tell you something important about these commands. As we saw earlier, the terminal is mostly used in a server environment. As most servers run under Linux, they use the Unix terminal.
I know that most of you use Windows, so you will be tempted to learn the commands of the MS-DOS terminal. But if you plan to work in server management, I strongly encourage you to learn Unix commands.
The terminal is a professional tool that allows you to perform many tasks manually. Its use, although complex, is very common in the professional world, and I encourage you to familiarize yourself with it, especially if you want to get into server administration or programming.
Écrit par Pythony le 29/12/2019.