You can navigate to the file system on your Mac while in the Terminal application using the cd command.
cd <path and/or folder name>
While the cd command is the most common method for a command line user, there are ways to use Finder to get to your destination. Dragging and dropping the folder into a Terminal window is one, and another is to use the context menu to start the Terminal application in the location of that folder.
My name is Eric, and as a software engineer for over 25 years, I have learned how to quickly navigate file and folder systems with command line tools such as Terminal.
I will show you some of my preferred ways to do this and provide tips to make things easier, so keep reading.
- Methods to Navigate to a Folder
- Using a Path with the cd Command
- Exploring your Disk with the cd command
- Quick commands to help Navigation using cd
- Two Methods using Finder
You can use several methods to navigate to a folder in Terminal Mac. If you are using the Terminal application regularly, I recommend getting comfortable using the cd command. It’s one you will use a lot, and you should know.
There are also a couple of ways to use Finder from your desktop to get there, and this can be an excellent method when you need to do this quickly. As with any task on your Mac, it is always good to know multiple methods for accomplishing them. Let’s take a look at some now.
Using a Path with the cd Command
The cd command is the old reliable way to get to any folder on your file system. There are a couple of different scenarios to consider. The first is that you already know the path where your folder exists. For the second one, you don’t know the path and need to find it.
Let’s see how to do this in each situation. To get started, you need to open a session of your Terminal application.
You Know the Path
This can be pretty simple if you already know the path of the folder to which you want to navigate. All you need to do is plug it into the cd command, as shown below.
For example, I have a folder called WebArt that I would like to navigate to. I already know that the path to the folder is /Users/ericwinkler/Test/WebArt. All I need to do is use the cd command, as shown below.
Find the Path
In many cases, you won’t know the path to the folder you need to navigate to. In this situation, you will need to use some method to find it. You can use any of the same methods that you would use to find the path to a file. Below I will use the find command.
find / -name <foldername> 2>/dev/null
or for my example
find / -name WebArt 2>/dev/null
Now I can select the path by highlighting it, then copy it, and then paste it to the end of my cd command.
Exploring your Disk with the cd command
Sometimes we may not know the exact name of the directory we are looking for, or maybe we have an idea of what contents will be in the folder but don’t know the name of it. We may want to look around and explore what is in our file system.
In this case, I can use the cd command to traverse up and down the hierarchy of our file system. I can do this by specifying single folders within my current directory to move to. I’ll need to use the ls -l command to see what folders are in our current directory.
If I want to move to the Test directory, I can use the cd command below.
Once in the Test directory, I can also use the pwd command, as seen in the image above, to show the path of my current location.
Using the ls -l command again, I can now see the list of folders underneath the Test directory, which is my current directory.
Here we see our WebArt folder used from the previous example. Now I can use the cd command again to move to this folder.
I am now in the WebArt folder. This is an empty folder, but I have used the ls -la command to show the contents. The a parameter tells the system to show all contents, even hidden ones. Notice the . and the .. entries that are shown as directories.
The . represents our current folder which is WebArt, and the .. represents the folder just above WebArt, which was called Test (full path would be /Users/ericwinkler/Test). So if I want to move back to the Test directory, I don’t need to specify the full path. I can use the .., which will always represent the folder or directory above my current directory.
While it can take some time, you can use this method to traverse up and down the folder structure on your file system. Using the cd <foldername>, the ls command, and cd .., we can easily move around and get to anywhere we want to go.
Once you begin using the cd command regularly, you will become more comfortable and learn tricks to make things a little easier and more natural. Below are some commands that can help you to get to where you are going quicker.
- cd – Go back to the previous directory you were just in.
- cd .. Move back one directory level.
- cd ~ Go to your home directory
- cd This will also take you to your home directory.
- cd / Go to the root directory.
- pwd shows your current directory
- ls -la lists the continents of the current directory showing details and hidden files and folders.
Two Methods using Finder
Above, we have learned how to navigate to a folder using the command line in Mac Terminal. It is important to know how to use the cd command and the methods shown above to move around the file system, but you can use a few quick techniques when needed.
These are nice methods, but you shouldn’t rely on them. Knowing how to navigate with the cd command is something that all command line users should learn and be comfortable with. With that being said, there are times when you want a quick method like the ones below.
Drag and Drop
This method works well if you already have a Terminal session opened and wish to quickly navigate there in that same Terminal window. All you need to do is open Finder, find or navigate to your folder, and drag and drop it into the Terminal window. Follow the steps below.
Step 1: Type cd and space in your Terminal window. (Do not hit return yet)
Step 2: Open Finder using your preferred method.
Step 3: Navigate to the folder that contains the folder you wish to go to in the Terminal. You can use the search feature if you are unsure of where it is.
Step 4: Click on the Folder name in Finder and hold the left button down.
Step 5: Drag the folder over to your Terminal window.
Step 6: Release the left mouse button to drop the folder into the Terminal window.
Step 7: Hit the return key in your Terminal window
You will now be in the folder.
This method works well when you want to open up a new Terminal session in the location of the folder that you want to navigate to. Use finder to get to the location and right-click to bring up the context menu. From there, you can open a Terminal session, and you are there.
For more detailed information, look at this article for step-by-step instructions on opening Terminal in a current folder on Mac.
Below are a few questions often asked when learning how to navigate to folders in Terminal Mac.
Why do I see a Permission Denied message?
You may see a permission denied message if the folder you are trying to navigate to does not have read permissions or is not owned by you. You will need to change the folder’s permissions using the sudo chmod command with your password.
sudo chmod 777 <foldername>
You should now be able to cd to the folder.
Why do some paths have a ./ at the beginning, some have a /, and others just have the folder name?
A path with a ./ or just the folder name at the beginning is a relative path, meaning it is relative to your location. If the path starts with just a /, it is an absolute path that begins from the root directory. Take a look here for more information on understanding paths.
Why does the find command show two different paths to my folder?
You will often see two different paths to your folder, especially when searching from the root directory, and you might wonder if they are the same folder. Usually, they are. One is from the location where your user files are mounted to the drive, and the other is the full system path to the volume on the disk drive. You will normally use the mounted one, which is the shorter of the two.
You can navigate to a folder in Terminal Mac in multiple ways. You should use the method that you find most comfortable but using the cd command is one that you should learn even if you prefer using finder with the drag and drop or context menu methods.
Have you found other ways that you like to use to navigate your Mac’s file system? I would love your feedback so let me know if you have any comments or questions.