Skip to main content
⚡ OpenDevDocs
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/api

2. 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.js or ../config.json).

3. Special Directory Symbols

SymbolMeaningExample
.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 rootcd /

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
popd

On this page