When we create a folder in macOS it is hosted in a specific location, call it desktop, documents, etc., each of these locations is called Directory. With the organization in Mac directories it is easier to have our information classified without it becoming chaos. Moving between Mac directories and files is a very common task, so it is useful to know how to change directories with the Mac terminal since it is faster..
The use of directories in macOS is key to define a hierarchical structure internally with which these objects are managed, we as users simply click on each route to go to the destination, but there are a series of useful commands with which we can switch between Mac directories and view their contents.
TechnoWikis will explain the use of the pwd, ls and cd commands in macOS..
To stay up to date, remember to subscribe to our YouTube channel! SUBSCRIBE
How to change directory on Mac terminal
View Mac terminal directory with PWD command
The command pwd (present working directory), as its name implies, lists the name of the directory in which we are currently in macOS, for this we enter the terminal (by default it will always be located in the user folder) and execute " pwd ”, when pressing the Enter key we will see the current directory:
View content of Mac terminal directory with LS command
This is a traditional command on UNIX systems with which we can list the contents of a directory, by executing "ls" we will see all the objects in the current directory:
Change Mac terminal directory with CD command
The cd (Change Directory) command allows us to switch between directories, for example, if we want to go to the desktop we execute the following:
Now that we are between directories, it is possible to use these commands for better content management. In the current directory, we can use the "pwd" command to see that we are located at:
Also, we can use "ls" to view everything on the desktop. This allows us to see the objects by type of extension.
There we can use the "cd" command to access the contents of some folder in this directory:
If we use the command "pwd" we will see the full path from the source directory to the current location:
If we are on this path and want to return to the main directory, in this case the desktop, we will use the following command.
cd ~ / desktop
Thanks to the use of these commands, we are able to work on the directories available in macOS and thereby take full advantage of each of them.