Quick take: The cd command — short for change directory — is the most fundamental navigation command in Linux.

The cd command — short for change directory — is the most fundamental navigation command in Linux. Every Linux user, from beginners to senior sysadmins, uses it dozens of times per session. This guide covers every variant of cd you will need in real-world Linux work.

Basic Usage — cd to a Directory

$ cd /path/to/directory

After running cd, verify your current location with pwd (print working directory):

$ pwd

cd with Absolute Paths

An absolute path starts from the filesystem root / and specifies the complete path to the destination:

$ cd /var/log/nginx
$ cd /home/irfan/projects
$ cd /etc/nginx/sites-available

Absolute paths work from any directory — they always lead to the same place regardless of where you currently are.

cd with Relative Paths

A relative path is relative to your current directory. If you are in /home/irfan and want to go to /home/irfan/projects/myapp:

$ cd projects/myapp

No leading / means the path starts from your current location.

Go to Your Home Directory

Three equivalent ways to return to your home directory (/home/username):

$ cd
$ cd ~
$ cd $HOME

All three do the same thing. cd with no arguments is the fastest to type.

Go Up One Directory — cd ..

Two dots (..) represents the parent directory:

$ cd ..            # Up one level
$ cd ../..         # Up two levels
$ cd ../../etc     # Up two levels, then into etc/

Go to the Previous Directory — cd -

The hyphen shortcut is one of the most useful cd tricks:

$ cd /var/log
$ cd /etc/nginx
$ cd -             # Returns to /var/log

cd - toggles between your current and previous directory. It is invaluable when you need to move back and forth between two locations repeatedly — a log directory and a config directory, for example.

Start typing a directory name and press Tab to autocomplete:

$ cd /var/lo[Tab]         # Completes to /var/log/
$ cd /etc/ngi[Tab]        # Completes to /etc/nginx/

If multiple directories match, press Tab twice to see all options.

Directories with Spaces — Quoting

If a directory name contains spaces, wrap it in quotes:

$ cd "My Documents"
$ cd 'My Documents'
$ cd My\ Documents       # Backslash escaping also works

cd Quick Reference

CommandWhat it does
cd /pathNavigate to absolute path
cd dirnameNavigate to relative path
cdGo to home directory
cd ~Go to home directory
cd ..Go up one directory
cd ../..Go up two directories
cd -Toggle to previous directory

Final Thoughts

The cd Command in Linux is worth reviewing with a practical lens: understand the risk or opportunity, map it to your environment, and take clear next steps instead of reacting to headlines.

FAQ: The cd Command in Linux

What should you know about Basic Usage — cd to a Directory?+

After running cd , verify your current location with pwd (print working directory).

What should you know about cd with Absolute Paths?+

An absolute path starts from the filesystem root / and specifies the complete path to the destination: Absolute paths work from any directory — they always lead to the same place regardless of where you currently are.

What should you know about cd with Relative Paths?+

A relative path is relative to your current directory. If you are in /home/irfan and want to go to /home/irfan/projects/myapp : No leading / means the path starts from your current location.

How do you go to Your Home Directory?+

Three equivalent ways to return to your home directory ( /home/username ): All three do the same thing. cd with no arguments is the fastest to type.

How do you go to the Previous Directory — cd -?+

The hyphen shortcut is one of the most useful cd tricks: cd - toggles between your current and previous directory. It is invaluable when you need to move back and forth between two locations repeatedly — a log directory and a config directory, for example.

Need help with infrastructure or security?

Work directly with Muhammad Irfan Aslam for Linux, cybersecurity, cloud, Docker, DevOps, CI/CD, or infrastructure support.

Hire Me for Support