cd Command: Tutorial & Examples
Change the current directory
The cd
(change directory) command is a shell builtin that allows you to navigate between directories on a Linux system.
To use the cd
command, you simply type cd
followed by the name of the directory you want to move to. For example, to navigate to the /home/user/documents
directory, you would type:
cd /home/user/documents
If you want to navigate to a subdirectory within the current directory, you can simply specify the subdirectory name. For example, if you are currently in the /home/user
directory and you want to navigate to the documents
subdirectory, you can type:
cd documents
There are also several special directories that you can use with the cd
command to quickly navigate around the file system. For example:
.
(a single period) refers to the current directory..
(two periods) refers to the parent directory of the current directory~
(a tilde) refers to the home directory of the current userFor example, if you are currently in the
/home/user/documents
directory and you want to navigate to the/home/user
directory, you can type:cd ..
Or, if you want to navigate to your home directory, you can type:
cd ~