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

in Mac by (552k points)
reopened | 740 views

1 Answer

+5 votes
Best answer

How to change directory on Mac terminal

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 (3.5m points)

Related questions

+4 votes
1 answer
asked Mar 29, 2021 in Mac by backtothefuture (552k points) | 152 views
+5 votes
1 answer
asked Jan 14, 2020 in Windows 10 by backtothefuture (552k points) | 340 views
+3 votes
1 answer
asked Apr 27, 2020 in Mac by backtothefuture (552k points) | 268 views
+3 votes
1 answer
asked Jan 25, 2021 in Mac by backtothefuture (552k points) | 216 views
+3 votes
1 answer
asked Sep 7, 2020 in Mac by backtothefuture (552k points) | 928 views
Sponsored articles cost $40 per post. You can contact us via Feedback

Most popular questions within the last 30 days

10,659 questions
10,791 answers
510 comments
3 users