Navigation and Listing
pwd, ls, cd, tree — moving around the filesystem without a mouse
Skills taught: linux.pwd, linux.ls, linux.cd, linux.filesystem-layout
Linux filesystem layout
/ root of the filesystem
├── bin/ essential command binaries (ls, cp, bash)
├── etc/ configuration files
├── home/ user home directories
│ ├── alice/ alice's home: ~
│ └── bob/ bob's home
├── usr/ user programs (most installed software)
│ └── bin/ non-essential binaries (most commands you run)
├── var/ variable data (logs, databases)
│ └── log/ system logs
├── tmp/ temporary files (cleared on reboot)
├── opt/ optional/third-party software
├── proc/ virtual filesystem: running processes info
└── dev/ device files
Navigation commands
# Where am I?
pwd # Print Working Directory → /home/alice/projects
# List directory contents
ls # basic list
ls -l # long format: permissions, owner, size, date
ls -la # include hidden files (dotfiles)
ls -lh # human-readable sizes (K, M, G)
ls -lt # sort by modification time (newest first)
ls -lS # sort by size (largest first)
ls /var/log # list a specific directory
# Change directory
cd projects # relative: go into 'projects' in current dir
cd /home/alice # absolute: go to exact path
cd ~ # home directory
cd # same as cd ~ (no argument = home)
cd .. # up one level (parent directory)
cd ../.. # up two levels
cd - # go back to previous directory
# Quick tip: Tab completes directory names
cd proj<Tab> # autocompletes to 'projects' if unique
Understanding ls -l output
drwxr-xr-x 3 alice staff 96 Oct 6 10:30 projects/
-rw-r--r-- 1 alice staff 1234 Oct 5 14:22 README.md
-rwxr-xr-x 1 alice staff 4096 Oct 4 09:15 deploy.sh
│ │ │ │ │ │ └─ filename
│ │ │ │ │ └─ modification date
│ │ │ │ └─ file size in bytes
│ │ │ └─ group owner
│ │ └─ user owner
│ └─ number of hard links
└─ permissions (d=directory, -=file, l=symlink, then rwxrwxrwx)
Permissions breakdown: drwxr-xr-x
d = directory
rwx = owner can read, write, execute
r-x = group can read, execute (not write)
r-x = others can read, execute
Tip: ~ is your home directory. It expands to /home/username (Linux) or /Users/username (macOS). Use ~ in paths: cd ~/projects, ls ~/Downloads. . means current directory, .. means parent directory.
Frequently Asked Questions
What is a dotfile?
Files and directories whose names start with a dot (.) are hidden by default — ls doesn't show them without -a. Dotfiles are used for configuration: ~/.bashrc (bash config), ~/.gitconfig (git config), ~/.ssh/ (SSH keys). The convention is that dotfiles are config files that shouldn't clutter normal directory listings.