English

How to get started with macOS Terminal? Return home Clubic

  • Home
  • Article
  • How to get started with macOS Terminal? Return home Clubic
 How to get started with macOS Terminal?  Return home Clubic
Images
  • By electronics-phone
  • 647 Views

Laurent Mancini December 17, 2021 at 4:03 p.m.

The macOS operating system has a native application named Terminal. This makes it possible to control the computer, through a textual interface, thanks to command lines. It is inherited from the original Unix environment, on which many OSes are based.

Anyone with even a bit of an interest in computing has heard the term “Terminal” before. It is also found, under the same name, in Windows or Linux OS. The Terminal saves a lot of time. It is thus possible to use it daily, with basic commands. Advanced users can also call on it for more advanced tasks. Once discovered and taken in hand, it quickly becomes indispensable. The terminal offers an absolute level of control over your machine. It is therefore essential to start well with this application.

How to open Terminal with a Mac?

Terminal is a utility, it can be accessed in several ways. You can go through the Finder (command+F), the Applications tab (shift+command+A), Utilities (shift+command+U) or via the Spotlight search engine (command+space). If you prefer to go through the GUI, then just use Launchpad (F4). This tool allows you to display, open and organize the different applications installed on your computer.

Once the Terminal application has been launched, it is possible to keep it on your desktop, by right-clicking, then “Options” and finally “Keep in dock”.

Don't be surprised by the forbidding aspect of the textual interface

No frills here… The Order Terminal is for pros and aims for efficiency. It's not really about ergonomics. This application does not seek to promote "user experience".

When opening the application, an almost empty window appears. Depending on the OS used, a message may alert you:

The default interactive shell is now zsh.

To update your account to use zsh, please run `chsh -s /bin/zsh`.

Indeed, since macOS Catlina, zsh is the default shell, instead of bash on earlier OSes.

But what is a shell?

It is nothing more than the English term for the system interface. The shell represents the primary part of your operating system. It is from this essential software layer that the rest derives. Thus, we speak of command lines or CLI (Command Line Interface) for the terminal and of graphical commands or GUI (Graphical User Interface).

Novice users will be content to know these different terms. For a first handling of the Terminal, it is not necessarily useful to deepen this technical aspect. The basic commands that we will discuss later can be used without fear, whatever your OS. Those who wish to know more about the subject, can refer to this article from Apple support.

Is using the Terminal risky?

Comment bien débuter avec le Terminal de macOS ? Retour accueil Clubic

Yes ! It is imperative to be aware of this. As mentioned above, the command lines act directly on the primary layer of the operating system. If they save considerable time on certain tasks, they can also cause significant damage. It is thus possible to generate looping requests, called “fork bombs” which will quickly saturate the computer.

Critical system files can also be inadvertently moved or deleted. It is therefore a question of being particularly attentive during manipulations on the Terminal. Confirmed users can also be trapped maliciously. Indeed, the advanced commands being sometimes very long, it is tempting to copy/paste them directly into the administrator console, without always taking care to re-read them carefully.

Fortunately, the administrator commands are not easily accessible. These must be entered in admin mode (also called root user or superuser). Fans of Mr. Robot or Person of Interest will no doubt be familiar with these technical terms.

Get started with Terminal on macOS

The Terminal uses the computer's default theme. If you are bothered by the white background of the Terminal window, it is possible to change it. To do this, simply use the application's Shell menu, then choose to open a new tab. You can then choose the theme that suits you best. Other options or advanced functions are also available and accessible in the preferences (command+,). The window can be moved, enlarged or reduced, like other applications.

When the working window opens, a blinking cursor indicates the command waiting. A Terminal command line has different parts. It is exclusively written in English. Commands are executed instantly, as soon as you press the Enter key. It is therefore advisable to read them carefully before any inconsiderate gesture.

The basic commands

Many commands must be completed with a precise indication. This represents the targeted file or folder. Commands are always separated by a space or a hyphen.

For example, to view the contents of a folder, we would write:

ls [nom du dossier]

If you want to move a file to a folder, you will have to proceed in the same way:

mv [nom du fichier origine] /home/Utilisateur/Bureau/[nom du dossier cible]

A little trick deserves to be mentioned here: to avoid typing the entire desired path, it is possible to drag the file directly to the Terminal window. You can also copy (command+C) the desired folder or file, then paste it (command+V). By launching the Terminal, we start the session while being in the working directory /[users]/[user name].

Access paths

Paths are absolute or relative.

An application can be opened using the command:

Open -a [nom de l'application]

Navigation between the lines is done using the arrow keys. As mentioned before, pressing the Enter key triggers the order.

Browse folders

To move within the different folders and directories you must use the cd function. So, cd.. takes you up one level, while cd / takes you back to the root of the tree. Be careful, because the different command lines act on the current directory… Are you lost? Don't panic: the pwd command tells you where you are in the tree structure.

This may seem a little complicated, but once you understand the principle, you will save considerable time. In the event of an error, the informative messages "command not found", "no such file or directory exist" will appear. They have no effect on the integrity of your system. All you have to do is rewrite your command line, taking care to respect the spaces, the case of the characters and the hyphens. It will also be necessary to check the conformity of the orders issued and the paths entered.

Some commands will trigger a process to appear. Several lines will then appear, sometimes with a percentage indicating the progress of the given order. Others, on the contrary, will seem to have no impact. A new line will pop up, with a blinking cursor, indicating that you are waiting for action. However, the command will have been executed.

The different orders available correspond mostly to English abbreviations. You find for example the commands mkdir for Make Directory or cd for Change Directory.

If you want to go further

The Terminal gives direct access to the guts of your computer. It is therefore a question of using this powerful tool with caution. Once seasoned with the basic commands, you can consider exploiting its full potential.

You can intervene on your home network or write your own scripts to automate certain tasks. It is also possible to use the Terminal more finely.

If you use the ls command to view the contents of a folder, for example, it is possible to add additional attributes to it.

The -i option will allow you to view the details of the files, their sizes, possible protections and many other information.

The -a option will make hidden files visible.

You can also create new directories using the command

mkdir [nom du répertoire].

Download (PDF)

More than 1400 orders are listed today. It is also possible to display them on an active Terminal, by pressing the escape (esc) key twice.

The uses of the Terminal have virtually no limits. You can download files from a URL, modify system settings and preferences or delete folders.

It is a powerful tool, which is mastered little by little...