Written byConnie Yang
Overview of CD Command in Terminal on Mac & Using Guide
Summary: This post will introduce everything about the cd command in Mac Terminal, including what it is and how to use it. If the cd command in Terminal on your Mac is not working, this post will also tell you the solutions. - From iBoysoft
Mastering the Terminal command lines helps you a lot to control your Mac. You learn the cd command in Mac Terminal but still don't what it is and how to use it.
No worries. This post covers everything about cd in Terminal on a Mac. You can follow this post to learn when and how to use this special command line.
Table of Contents:
- 1. What is the CD command in Terminal on Mac?
- 2. How to use the CD command in Terminal on Mac?
- 3. How to go back to the previous directory in Terminal on Mac?
- 4. CD in Mac Terminal is not working, what to do?
What is the CD command in Terminal on Mac?
The cd command is short for Change Directory. It is used to change between directories in the Terminal on a Mac. By the way, a directory in macOS refers to a folder for storing files.
The cd command can help you change into a subdirectory (subfolder), move back into the parent directory (folder), directly return to the root directory (root folder), or move to any directory you give the path.
When using the cd command to move to the target directory, the name of the target directory (also the desired folder) is required to be taken as the argument.
Share it to help others get an overview of the cd in the Mac Terminal.
How to use the CD command in Terminal on Mac?
You can use the cd command to navigate to a folder in Terminal on your Mac.
Here's how to navigate to a folder using cd in Terminal on your Mac:
- Open Terminal (Launchpad > Other) on your Mac.
- Type cd followed by the path of the target directory (folder) and then press Return. For instance, if you want to move to the Downloads folder in your home directory, enter the following command. The ~ symbol represents the home directory on your Mac. cd ~/Downloads
- The cd command to open the home folder: cd ~
- The cd command to open the Documents folder: cd ~/Documents
- The cd command to open the Applications folder: cd ~/Applications
- The cd command to open the Applications folder: cd ~/Desktop
Then, you can type ls to list files in the current directory in Mac Terminal.
How to go back to the previous directory in Terminal on Mac?
There are two types of cd commands available for you to return to the previous directory in Terminal on your Mac.
cd .. (note that is two periods): go back to the directory above the current one you're in. For example, if you are in the Documents folder, cd .. will lead you back to your home directory (~).
cd - (note that is the hyphen): return to the directory you were in before the last cd you typed in. For example, you are in the home directory (~) now, and before it, you enter cd ~/Documents to open the Documents folder. Now, cd - will bring you back to the Documents folder.
CD in Mac Terminal is not working, what to do?
If the cd command in Terminal can't lead you to the directory you want, you can check the following solutions.
Check if you run the cd command correctly in the Terminal
If you type in the wrong cd command in Terminal, it is invalid and won't take you to the target directory. Whenever you enter a cd command, check your edition.
For instance, cd ~/Downloads, there's space between cd and ~, and a /before the folder name.
The terminal may be temporarily broken, causing it not to react to the entered command. You can reopen it for a refresh.
Update your Mac
If the Terminal not working issue happens after a macOS update, it is probably caused by the bugs in the current system. Check if there are minor updates available and update your Mac.
If this post helps you understand cd command in Terminal deeply, share it with others.