Linux
linuxlinuxGuideBeginner
Linux Command-Line Navigation
Navigate directories efficiently using pwd, cd, relative and absolute paths, tilde shortcuts, and pushd/popd.
Verified: 2026-09-30
Tested on:linux Ubuntu 24.04 / Debian 12
Platforms:
linuxmacos
#linux#navigation#cd#pwd#cli
1. Print Working Directory (pwd)
Displays the absolute path of your current location in the filesystem:
pwd
# Output: /home/alice/projects/api2. Absolute vs Relative Paths
- Absolute Path: Begins with
/and specifies the complete path from the filesystem root (e.g./var/log/nginx/access.log). Always points to the exact same file regardless of current directory. - Relative Path: Specifies a path relative to your current working directory without a leading
/(e.g.src/index.jsor../config.json).
3. Special Directory Symbols
| Symbol | Meaning | Example |
|---|---|---|
. | Current directory | ./run.sh |
.. | Parent directory (one level up) | cd .. |
~ | Current user's home directory (/home/username) | cd ~/downloads |
- | Previous working directory (toggle back and forth) | cd - |
/ | Filesystem root | cd / |
4. Advanced Directory Stacks (pushd & popd)
Instead of losing your place when navigating deeply into temporary subdirectories:
# Save current location and switch to /var/log
pushd /var/log/nginx
# Inspect files...
ls -la
# Pop back to your exact previous working directory
popdLinux Filesystem Hierarchy Standard (FHS)
Master the Linux directory tree layout (/etc, /var, /home, /bin, /usr, /proc, /tmp) and where software stores files.
Working with Files & Directories in Linux
Create, copy, move, rename, read, and delete files and directories in Linux using touch, mkdir, cp, mv, cat, less, and rm.