Comprehensive Guide to the ‘cd’ Command: Mastering Terminal Navigation

Terminal navigation is a fundamental skill for any user of Unix-based systems such as macOS or Linux. The command line provides powerful tools for navigating your system’s file hierarchy, and understanding these tools can significantly boost your productivity. One such tool is the cd command. This article will guide you through the ins and outs of navigating directories using cd, turning you into a terminal navigation pro in no time.

Understanding the ‘cd’ Command

The cd command, short for “change directory”, is used to navigate between different directories in your system. The basic syntax is simple:

cd directoryName

Replace directoryName with the name of the directory you want to navigate to. If the directory is located in your current directory, you can simply use its name. Otherwise, you’ll need to provide the full path.

Using Relative and Absolute Paths

When using cd, you can specify either a relative path or an absolute path. A relative path is defined with respect to the current directory, while an absolute path starts from the root directory, signified by a leading slash (/).

For example, if you’re in the directory /Users/username/Documents, you can navigate to the Work subdirectory using a relative path:

cd Work

Or you can use an absolute path to navigate directly from any location:

cd /Users/username/Documents/Work

Special Directories and Shortcuts

Here are a few special directories and shortcuts that can help you navigate more efficiently:

  • . represents the current directory.
  • .. represents the parent directory.
  • ~ represents the home directory.
  • - represents the previous directory.

For example, to navigate to the parent directory, you can use:

cd ..

To return to the previous directory, you can use:

cd -

And to go back to your home directory, you can use:

cd ~

Or simply:


Verifying Your Location with ‘pwd’

As you navigate around your system using cd, it can sometimes be easy to lose track of which directory you’re currently in. This is where the pwd command comes in handy.

The pwd command, which stands for “print working directory”, displays the full path of your current directory. It’s a quick and easy way to confirm your current location in the file system. Here’s how you use it:


Running this command will output the absolute path of your current directory. For example:


This command can be particularly useful when you’re working with complex directory structures or when you’re using relative paths with the cd command. By regularly using pwd, you can ensure that you always know your current context, helping you to navigate your system more confidently and efficiently.


The cd command is a basic yet powerful tool for navigating your system’s directory structure from the terminal. By mastering cd and its associated shortcuts, you can move around your system with ease and speed, harnessing the full power of the command line. Happy navigating!


Whilst building web applications, Daniel also sets up web servers from scratch because he has yet to find the perfect hosting solution. His philosophy is “Why settle, when you can build it better yourself?”

Recent Posts