macOS is interesting because it will suit everyone: beginners will enjoy the intuitiveness and clarity of the interface, and experienced users will benefit from virtually unlimited possibilities that are hidden “under the hood” of the system. To work with them, we need a completely different, already unusual for modern computer users method – the command line. Using the command line, you can manage your computer and files on it, the settings of almost all programs, system processes, and much more. Moreover, many interesting features of macOS can be activated and many problems can be fixed only via the command line. The window to this interesting world for you will be the macOS Terminal. I decided to devote our capabilities to this cycle of articles, in which we consider the most useful commands and parameters for the ordinary user.
For a start – a small introduction. Many users will ask the question “why do I need a terminal with some kind of command line, when I have a nice and convenient Finder interface and dozens of similar third-party programs at my disposal?” I will honestly answer you – you do not need a terminal. But only until you have problems with your OS or until you want to change something in the hidden settings of the system. The complexity of the command line interface is contrived, you just need to understand the scope of applicability of the Terminal. For some tasks, it makes no sense to use it, because it will be much faster to do this by standard means. But, for example, not a single clever program will give you such batch processing options for files that are provided in the Terminal.
Read more: How to use SSH on a Mac?
In this article we will be devoted to the most important thing – navigating through folders via Terminal. Without this, you will not be able to do anything in the Terminal.
Table of Contents
Gray rectangle – this is the cursor. There is no familiar mouse pointer in the command line. To the left of the cursor is a meaningless (at first glance) set of characters. But in fact, the meaning here is in the details of the coad. Next parameters are:
- Mac-Admin is the name of the computer. Of course, you will have it completely different, the colon separates the name of the computer;
- Next follow the name of the folder where you are ~ or / means you are in the user’s home folder or root folder;
- admin$ is a username.
These elements are called invitations. If you see them on the screen, then the Terminal is ready to listen to your command. If there is no invitation and no cursor, then the execution of the previous commands has not yet ended, and it is not possible to enter new ones yet.
The Terminal shows only the name of the current folder on the left. This does not mean anything, because there may be several folders with the same name on the computer.
Before proceeding to the study of commands is important another function that will simplify the method of entering commands in the Terminal. If you need to enter several similar commands, do not need to enter each again and again. The “Up Arrow” and “Down Arrow” allow you to scroll through all previously entered commands.
Therefore, remember the first and most important navigation command:
This is the abbreviation of the Print Working Directory – print working directory. It will show you the path to the folder in which you are located.
Type “pwd” in the Terminal and press Enter. You will see the following:
Having launched the Terminal (it lies in the Programs / Utilities folder), you will see the following window:
- / – is the designation of the root folder of the drive on which macOS is installed;
- /Users is a user folder located in the root folder of the disk;
- /Users/admin is the current user folder, which is located in the users folder.
How to move to another folder? Very simple.
Remember the second most important command:
cd means Сhange Directory – change folder. For this command, it is not enough to enter its name – so you just say that you want to change the folder, but you do not say where you want to go. Therefore, after cd, you need a space and the path to the directory to which you want to move.
For example, enter:
This will take you to the root of the disk (do not forget to press Enter – as always).
Your home folder is not in vain denoted by a tilde. So that you do not have to drive in /Users/user_name/ each time in the Terminal, this useful abbreviation was invented.
Type in the command line
And you will again find yourself in your home folder.
The cd command has several features related to folder paths. Paths are of two types:
- absolute – from the root of the disk. They always begin with a slash (/);
- relative – from the current folder.
Remember another useful abbreviation – two dots (..). This is a transition to a higher level – to the parent folder. For example, if you are in the /Users/admin, and enter into the Terminal:
After “Enter” you will be in the /Users.
And the last trick of the Terminal for today: if you need to open the current directory in the Finder window, you should enter the following command into the terminal:
After you press “Enter”, the Finder window in current directory will appear above the Terminal window.
I hope this is a small introduction to the basics of the world command line, not too tired you. In the next section, we will look at how to view and manage the contents of directories and files via Terminal.