The cd
command is used to change the current working directory (i.e., in which the current user is working).
The "cd" stands for 'change directory.' an it is one of the most frequently used commands in the Linux terminal.
The cd
command stands for chdir
(Change Directory), Often combined with the ls
command that shows files and folders, cd
allows you to navigate through folders/directorys, Much like navigating through chapters and pages in a book.
It Normally Lists the files and directories in ascending alphabetical order after typing cd
and pressing TAB
2 times.
- To change our current working directory, execute the command as follows:
cd <specified_directory_path>
- To change the directory to home directory from the current working directory, execute the command as follows:
cd ~
or simply
cd
- To change to the previous directory from the current working directory, we can execute this command:
cd -
It will also show you the absolute path of your previous working directory
- To navigate to the system's root directory from current working directory, execute the command as follows:
cd /
- To navigate through multiple folders:
cd {Directory_Path}
cd /home/user/101-linux-commands-ebook/ebook/en/content/
Adding a ..
as a directory will allow you to move "up" from a folder, this can be done multiple times too!
eg. cd ..
to move up one folder or cd ../../../
to move up 3!
cd [OPTIONS] directory
Short Flag | Long Flag | Description |
---|---|---|
-L |
- | Follow symbolic links. By default,cd behaves as if the -L option is specified. |
-P |
- | Don’t follow symbolic links. |