When you work in the Linux terminal, knowing how to go back a directory is essential for efficient navigation. Whether you are exploring project files or managing server logs, moving up one level helps you keep your workflow smooth and focused.
This guide shows practical commands and common patterns so you can move up the directory tree with confidence and precision.
| Command | Action | Scope | Notes |
|---|---|---|---|
cd .. |
Move up one directory level | Relative path | Works from any current working directory |
cd ../.. |
Move up two directory levels | Relative path | Useful to jump further up the tree quickly |
cd ~ or cd |
Go to your home directory | Absolute path | Fast way to return to a known safe location |
cd - |
Switch to the previous directory | Session history | Toggles between the last two locations |
Using cd .. to move up one level
The most common way to go back a directory is to use cd with two dots. This relative path tells the shell to move up to the parent folder of your current location.
Behavior in different scenarios
Running cd .. works consistently across most shells and environments. It changes the current working directory without requiring an absolute path, which makes scripts portable and interactive sessions fast.
Navigating multiple levels with relative paths
If you need to go back more than one directory, you can extend the relative path by adding additional dots and slashes.
Examples of deeper traversal
Commands like cd ../.. move up two levels in a single step, while cd ../../.. moves up three levels. You can combine this pattern to reach any ancestor directory efficiently.
Returning to your home directory
Sometimes you want to jump directly to a known safe location instead of stepping back incrementally. The tilde provides a quick way to go home.
Home shortcuts and convenience
Using cd ~ or simply cd takes you to your home directory instantly. This approach is helpful when you need to reset your position without counting directory levels.
Switching between recent locations
The dash mechanism lets you move back to the directory you were in before your current location, making it simple to toggle between two places.
How cd - works in practice
After you run cd /some/deep/path and then cd ~, executing cd - returns you to that deep path. This toggle behavior is ideal for moving back and forth during complex navigation tasks.
Key takeaways for directory navigation
- Use cd .. to move up one level in the directory tree
- Combine dots and slashes to go up multiple levels at once
- Jump to your home directory with cd ~ for a known starting point
- Toggle quickly between two locations with cd -
- Remember that cd .. from root keeps you in place safely
FAQ
Reader questions
What happens if I run cd .. from the root directory?
Nothing changes; you remain in the root directory because there is no parent directory above it.
Can I use cd .. inside a symbolic link?
Yes, cd .. works based on the current working directory path, following symlinks if your shell resolves them, but it moves to the parent of wherever the link points.
How does cd .. interact with the cd - command?
Each cd .. updates the directory stack used by cd -, so toggling with cd - will return you to the exact location before you moved up.
Is there a way to go back a directory without typing cd ..?
You can use the shell abbreviation .. with some advanced shell plugins, but the standard and most portable method remains cd ..