+4 votes
50 views
Change Directory in Terminal Mac | PWD, LS and CD Commands

in Mac by (274k points)
reopened | 50 views

1 Answer

+5 votes
Best answer

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:

 

image

 

 

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:

 

image

 

 

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:
 cd desktop 
image

 

 

Step 1

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:

 

image

 

 

Step 2

Also, we can use "ls" to view everything on the desktop. This allows us to see the objects by type of extension.

 

 

image

 

 

Step 3

There we can use the "cd" command to access the contents of some folder in this directory:

 

image

 

 

Step 4

If we use the command "pwd" we will see the full path from the source directory to the current location:

 

image

 

 

Step 5

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 
image

 

 

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.

 


by (1.7m points)

Related questions

+5 votes
1 answer
asked Jan 14 in Windows 10 by backtothefuture (274k points) | 26 views
+3 votes
1 answer
asked Apr 27 in Mac by backtothefuture (274k points) | 9 views
+5 votes
1 answer
asked Nov 15, 2019 in Mac by backtothefuture (274k points) | 134 views
+5 votes
1 answer
asked Sep 20, 2019 in Mac by backtothefuture (274k points) | 45 views
+5 votes
1 answer
asked Nov 14, 2019 in Linux / Unix by backtothefuture (274k points) | 23 views
Please leave a comment about whether the solution works or not (with device model)   [X]Close
5,210 questions
5,300 answers
106 comments
2 users