Goal
By the end of this lesson you will be able to move around any Linux server quickly, understand where you are, and find what you need without guessing.
This is not about memorizing commands. It is about building a mental model of paths.
Mental Model (2 minutes)
Think of the filesystem as a tree. Everything is a path.
/
├─ home/
│ └─ rahul/
│ ├─ projects/
│ └─ notes.txt
├─ etc/
├─ var/
└─ tmp/
You always have:
- a current directory (your location in the tree)
- a target path (where you want to go)
Core Commands You Must Know
1) Where am I?
pwd
Prints the full absolute path of your current directory.
2) What is here?
ls
ls -lah
Useful flags:
-l: long listing (permissions, owner, size, time)-a: include hidden files (starting with.)-h: human sizes (K, M, G)
3) Move to another folder
cd /etc
cd ..
cd ~
cd -
Important shortcuts:
.= current directory..= parent directory~= your home directorycd -= jump back to the previous directory
Absolute vs Relative Paths (the most important concept)
Absolute path
Starts from root /.
Example:
cd /var/log
Relative path
Starts from where you currently are.
Example:
cd logs
This only works if a folder named logs exists inside your current directory.
Hidden Files (dotfiles)
Hidden files start with . (like .env, .git, .ssh).
ls -a
Common mistake: people think the file is missing, but it is hidden.
Reading a Directory Listing (like a DevOps engineer)
ls -l
The first character in permissions shows the type:
-regular fileddirectorylsymlink (shortcut)
If you see a symlink:
ls -l somefile
readlink -f somefile
Practical Navigation Patterns (what you do in real work)
Jump into logs and back fast
cd /var/log
ls -lah
cd -
Use tab completion (speed)
Start typing and press TAB:
cd /va<TAB>
Create a safe sandbox in /tmp
mkdir -p /tmp/devopslabx-lab
cd /tmp/devopslabx-lab
Finding Things (basic, but extremely useful)
Find by name (fast enough for most tasks)
find . -maxdepth 3 -name "*.log"
find /var/log -type f -name "*.log" 2>/dev/null
Find by content (logs, configs)
grep -R "ERROR" .
grep -R "listen" /etc/nginx 2>/dev/null
Exercises (do these)
Exercise A: Build your navigation muscle
- Create folders:
mkdir -p lab/a/b/c
- Move into
cusing a relative path. - Move back to
labusing... - Jump to your home directory.
- Jump back using
cd -.
Exercise B: Hidden files
- Create a hidden file:
touch .secret
- Confirm you cannot see it with
ls. - Confirm you can see it with
ls -a.
Exercise C: Find + grep
- Create a file with a few lines containing the word
deploy. - Use
grepto find those lines. - Use
findto locate that file by name.
Troubleshooting Checklist
If cd fails:
- did you type the path correctly (case matters)
- are you using relative path but you are in the wrong folder
- do you have permissions (try
ls -ld <dir>)
If a file is missing:
- is it hidden (
ls -a) - is it a symlink to somewhere else (
ls -l)
Quick Cheat Sheet
pwd # where am I?
ls -lah # what's here (including hidden)
cd /path/to/dir # go to absolute path
cd .. # go up one level
cd ~ # home
cd - # previous directory
find . -name "*.yml" # search by name
grep -R "text" . # search by content
Next Step
Once navigation feels easy, you are ready for permissions (chmod, chown) and services (systemctl) because you will always know where configs and logs live.