The “cd” Command – Learning How to Use Terminal (Shell) [Tutorial]

Although you can use this tutorial independently from the other ones from the “Learning How to Use Terminal (Shell)” series, you can check out the intro and ls  command tutorial right here.

An important part of harnessing the power of the Shell, is learning how to navigate and manipulating the file system. To change the directory you use the cd  command.

cd  command – change the directory/folder of the terminal’s shell.

The syntax for the command is:

Typing this command by itself returns you to your home directory; moving to any other directory requires a pathname.

You can use absolute or relative pathnames. Absolute paths start at the top of the file system with / (referred to as root) and then look down for the requested directory; relative paths look down from your current directory, wherever that may be.

The following directory tree illustrates how cd operates:

A path is absolute if the first character is a /. Conversely, if the first character is not a /, then it is a relative path.

Using relative paths allows you to change to a directory relative to the directory you are currently in, which can be convenient if you are changing to a subdirectory within your current directory.

cd  command examples:

Change to directory name with white space

There are 3 main ways to do it:


Changing to a directory that is a few levels up:


If you want to learn more about terminal, visit the previous tutorial I made, which gives you a nice intro on it and explains the ls  command used for listing files and directories. Or check out the next tutorial article on how to copy and move files using the terminal.

Hope you enjoyed this tutorial, and found it useful! And I’ll be doing more on this subject in the near future therefore don’t forget to subscribe to my Newsletter to get the latest posts! Also follow me on Social Media!




Comments 2

Leave a Reply