The Linux File System
Everything in Linux is organized in a tree structure starting from the root directory /. Understanding this hierarchy is essential for DevOps work.
Key Directories
/
├── home/ # User home directories
├── etc/ # System configuration files
├── var/ # Variable data (logs, databases)
├── usr/ # User programs and utilities
├── tmp/ # Temporary files
├── opt/ # Optional/third-party software
├── bin/ # Essential command binaries
├── sbin/ # System administration binaries
└── dev/ # Device files
Navigation Commands
pwd — Print Working Directory
# Shows your current location
pwd
# Output: /home/usernamels — List Directory Contents
# Basic listing
ls
# Detailed listing with permissions
ls -l
# Show hidden files
ls -a
# Combine flags
ls -la
# Human-readable file sizes
ls -lhcd — Change Directory
# Go to home directory
cd ~
cd
# Go to root
cd /
# Go up one level
cd ..
# Go to previous directory
cd -
# Navigate to a specific path
cd /var/logPaths
Absolute Paths
Start from root /:
cd /home/username/documents
cd /etc/nginx/conf.dRelative Paths
Start from current directory:
# If you're in /home/username
cd documents # Goes to /home/username/documents
cd ../otheruser # Goes to /home/otheruser
cd ./projects # Goes to /home/username/projectsUseful Shortcuts
| Shortcut | Description |
|---|---|
~ | Home directory |
. | Current directory |
.. | Parent directory |
- | Previous directory |
| Tab | Auto-complete |
| Tab Tab | Show all options |
Practice Exercises
Try these commands in sequence:
# 1. Check where you are
pwd
# 2. Go to the root directory
cd /
# 3. List all top-level directories
ls -l
# 4. Navigate to /var/log
cd /var/log
# 5. List log files
ls -la
# 6. Go back home
cd ~
# 7. Create a practice directory
mkdir -p devops-practice/linux
# 8. Navigate into it
cd devops-practice/linux
# 9. Confirm your location
pwdSummary
You now know how to:
- Understand the Linux file system hierarchy
- Navigate using
cd,ls, andpwd - Work with absolute and relative paths
- Use shortcuts for faster navigation
Next Steps
Next, we'll learn about file operations — creating, copying, moving, and deleting files and directories.