How to Go Up Multiple Directories in a Shell?

You can go up multiple levels in a directory structure by using the cd command in a shell followed by the desired number of ../ sequences. For example, to move up three levels, you would use the following command:

cd ../../../

Depending on the shell you're using, you can also create a shortcut in your shell configuration file for moving multiple levels up in a directory structure.

Please note that the cd command only changes the current directory for the current shell session. If you open a new terminal window (or log out and log back in), your current directory will revert to your home directory.

This post was published by Daniyal Hamid. Daniyal currently works as the Head of Engineering in Germany and has 20+ years of experience in software engineering, design and marketing. Please show your love and support by sharing this post.