Categories
Random Software Development

How to go back multiple directories in a linux terminal command line

Often when I am using the command line in a terminal on Linux I need to go back more than one directory. Usually you use the command

cd ..

Which takes you back one level in a directory. For example if you are in /var/www/http and you type cd .. you will be in directory /var/www/.

But what if you are super deep in the directory and need to get back to www directory. Say you are in /var/www/http/website/public and you want to get back to /var/www/http you can either type:
cd .. ( inside /var/www/http/website/ )
cd .. (inside /var/www/http/ now )

But you can type the following and get all the way back to the /www/http/ directory in one line
cd ../..
That line will take you back two directories. If you need to go further back just continue adding ../..

One reply on “How to go back multiple directories in a linux terminal command line”

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.