Change Directory with cd

If you are using the a linux command line, cd is an important tool to master to be able to navigate through directories as you need. Below are some useful snippets:


Return to a previous folder

Using the hyphen, you can return to the previous directory/folder before you navigated to the current directory

cd -

Return to a parent folder

You can use the double .. to return to the parent folder of the current working directory.

cd ..

Return to home directory

The special command cd with a tilde returns the user to the home directory irrespective of where the terminal is in the file system.

cd ..

Return to Root

Using the / with the cd command directly returns you to the root directory irrespective of where you are in the file system.

cd /