cd (Change Directory)
The cd command stands for Change Directory. It is the most fundamental navigation command used to move between different folders in the Linux filesystem.
1. Basic Usage
cd [path]
- Running
cdby itself without any arguments will take you back to your home directory (~).
2. Common Navigation Shortcuts
| Command | Destination |
|---|---|
cd . |
Current directory (no change) |
cd .. |
Parent directory (move up one level) |
cd ~ |
The user's home directory |
cd - |
Previous working directory (like a "back" button) |
cd / |
The system's root directory |
3. Absolute vs. Relative Paths
① Absolute Path
Specifies the location starting from the very top of the filesystem (the root /). It always works regardless of your current location.
cd /var/log/apache2
② Relative Path
Specifies the location relative to your current working directory.
cd projects/python # Move into a subfolder
cd ../../etc # Move up two levels, then into 'etc'
4. [Tip] Efficiency with Tab Completion
Never type out long directory names. Type the first few characters and hit the Tab key. The shell will finish the name for you. If there are multiple matches, hitting Tab twice will list all possibilities.
cd Doc[Tab][Tab]
# Documents/ Downloads/