Skip to main content

cd shortcuts: Moving Back

Once you can go forward, you need to know how to come back. These three shortcuts cover the most common navigation moves.

cd .. — go up one level

.. always means "the parent directory". No matter how deep you are:

pwd
# /home/user/documents/projects

cd ..
pwd
# /home/user/documents

cd ..
pwd
# /home/user

You can also chain them: cd ../.. goes up two levels in one command.

cd ~ — go home

~ is a shortcut for your home directory (/home/user). It works from anywhere:

cd /some/very/deep/path
cd ~
pwd
# /home/user

cd with no arguments also goes home:

cd
pwd
# /home/user

cd - — go back to the previous directory

- means "wherever I was before". Useful for toggling between two locations:

cd /home/user/documents
cd /home/user/downloads
cd - # back to /home/user/documents
cd - # back to /home/user/downloads

Summary

CommandEffect
cd ..Go up one level
cd ~ or cdGo to home directory
cd -Go back to previous location
cd /absolute/pathGo directly to a path

Practice

You start in the documents directory. Use cd .. or cd ~ to navigate back to your home directory.

Loading terminal…
Donate to this project