cd (Change Directory)
The cd
(Change Directory) command is used to change the working directory. On the GUI, you can use your mouse to select a directory or file through Finder on Mac or Explorer on Windows. On the CUI, you need to use your keyboard to move your Working Directory to a different location with the cd
command.
Special Characters to specify directories
Before explaining the cd command syntax, it is important to learn some special characters used for specifying certain directories.
/
(slash): root directory.
(dot): working directory..
(double dot): parent directory~
(tilde): user's home directory
The cd command
As you can see below, the command syntax is simple. You can use both an absolute path and a relative path to specify the directory path.
cd [directory path]
Here are some examples of the cd
command
To go to the root directory
cd /
To go to the parent directory
cd ..
To go to the home directory
cd ~
If you don't add a directory path, your working directory goes to the home directory as well.
cd
To go to the child directory named directory_a
cd directory_a