Navigating directories is one of the most used (and most basic) skills you will develop when using Unix-like operating systems.
cd is essential to properly navigate, a filesystem from a shell.
cd is short for "change directory". The command accepts an absolute path or a relative path as an argument, and changes your current working directory to the given location. This is something that you have been doing your whole life (like when you are trying to find a file on your computer; you change directories a lot!).
If you were to attempt to navigate into a folder using a GUI, you would double-click on the folder with the name that you would like to navigate to. Using
cd, it is almost as easy. Simply type
cd into your terminal, followed by the name of the directory that you would like to navigate to. If you wanted to navigate into the
school folder on your computer, you would do following.
This changes your working directory to the path of the
school directory. Remember, if you want to print your current working directory, you can use the
Sometimes, you will find that you are in the wrong folder, and instead you want to be in the parent directory (the directory that contains the directory you are currently in). To go "up one level" to the parent directory, you can use the
.. file path.
.. is a shortcut for "parent directory". You can read more about
An example of this would be the following scenario. Let’s say that you mistakenly navigated into the
school directory (
/home/john/project/school), and want to go to the
project directory (the parent directory for
school). To do so, you could run the following command.
Note that there is a space between
cd is a very powerful and simple tool, and soon you will find yourself using it without even knowing. Remember when we said "Using
cd, is almost as easy" (as using a GUI) — well in fact, it is easier! If you are double-clicking through a deep set of folders, it could take you a while to get to the right place. With
cd, you can navigate to your desired directory with a single command.