Linux cd Command
Linux cd Command
The cd
command in Linux stands for Change Directory. It is used to move between directories in the filesystem. This command helps users navigate through different folders while working in the terminal.
Syntax
The general syntax of the command is as follows:
$ cd [directory]
– directory: The path of the directory you want to switch to.
– If no directory is provided, it will take you to your home directory.
Examples
Move to a specific directory
$ cd /home/user/Documents
Go back to the home directory
$ cd
Move one level up (parent directory)
$ cd ..
Move two levels up
$ cd ../..
Explanation:
-
cd
→ change directory. -
..
→ represents the parent directory (one level up from the current directory). -
../..
→ means go two levels up from the current directory.
Example:
If your current path is:
/home/testingdocs/Documents/Projects
- cd .. → moves to /home/testingdocs/Documents
- cd ../.. → moves to /home/testingdocs
- So, this command is simply a shortcut to go two directories up in the file system hierarchy.
Go back to the previous directory
$ cd -
Use ~ for home directory shortcut
$ cd ~/Downloads
The cd
command is one of the most essential Linux commands. It allows you to navigate through the Linux file system easily, making it a must-know for beginners and experienced users alike.