Linux CLI 2 ๐ง Filesystem Navigation
Linux organizes files in a hierarchical directory structure โ a tree pattern starting from the root directory (/). Understanding how to navigate this tree is one of the most fundamental skills in the command line.
Introduction
cd /
ls
ls -la
| Command | Description |
|---|---|
cd / | Move to the root directory |
ls | Show files and folders in the current directory |
ls -la | Show detailed information (permissions, owners, sizes, hidden files) |
Key concept:
- Unix-like OSes (like Linux) organize files in a hierarchical directory structure
- They’re organized in a tree pattern
- The first directory is the root directory (
/) - Under the root there are files and subfolders
- Storage devices are mounted (attached) at various folders on the tree
Note: What you see depends on who the user is โ permissions affect what you can access.
The Filesystem Tree
/ โ Root directory
โโโ bin/ โ Essential binaries (ls, cp, mv)
โโโ boot/ โ Boot loader files
โโโ dev/ โ Device files (disks, terminals)
โโโ etc/ โ System configuration files
โโโ home/ โ User home directories
โ โโโ kronos/ โ Your home directory
โ โ โโโ Documents/
โ โ โโโ Downloads/
โ โ โโโ test/ โ Example subdirectory
โ โโโ anotheruser/
โโโ lib/ โ Shared libraries
โโโ media/ โ Removable media (USB, CD)
โโโ mnt/ โ Temporary mount points
โโโ opt/ โ Optional software
โโโ proc/ โ Process information (virtual)
โโโ root/ โ Root user's home
โโโ sbin/ โ System binaries
โโโ srv/ โ Service data
โโโ sys/ โ System information (virtual)
โโโ tmp/ โ Temporary files
โโโ usr/ โ User programs and data
โ โโโ bin/
โ โโโ lib/
โ โโโ share/
โโโ var/ โ Variable data (logs, spools)
โโโ log/
โโโ tmp/
Everything on Linux starts at / โ including USB drives, external disks, and network shares. They’re “mounted” at specific directories in this tree.
Current Working Directory
pwd
cd home
ls
pwd
cd test
cd ..
| Command | Description |
|---|---|
pwd | Print Working Directory โ shows where you are |
cd home | Move into the home directory |
ls | List contents of the current directory |
cd test | Move into the test subdirectory |
cd .. | Move up one level (to the parent directory) |
Key concepts:
- The current working directory is where you are right now in the tree
pwddisplays it โ like a “you are here” marker/homeis a path; its parent folder is the root//home/testis a path;test‘s parent ishome, which is a child of root/cd ..moves to the parent directory (one level up)
Path example:
/ โ root
โโโ home/ โ child of root
โโโ test/ โ child of home, 2 levels deep
Navigating up:
# If you're in /home/test:
cd .. # Moves to /home
cd ../.. # Moves to /
cd / # Also moves to /
Tip:
..means “parent directory”. Chaining them (../..) moves up multiple levels.
User’s Home Directory
cd
cd ~
cd ~anotherUserName
cd -
| Command | Description |
|---|---|
cd | Changes to your home directory |
cd ~ | Also changes to your home directory (~ = home) |
cd ~anotherUserName | Changes to another user’s home directory |
cd - | Changes to the previous working directory |
Detailed breakdown:
| Syntax | Meaning |
|---|---|
cd | Shortcut for cd ~ โ goes home |
~ | Tilde โ shorthand for your home directory (e.g., /home/kronos) |
~user | Tilde + username โ another user’s home |
- | Dash โ the previous directory (like “back” on a browser) |
Examples:
# You're in /home/kronos/test
cd # Now in /home/kronos
cd /etc # Now in /etc
cd - # Back to /home/kronos
cd - # Back to /etc
Pro tip:
cd -is a quick way to toggle between two directories โ perfect for switching back and forth between your project folder and your notes.
Complete Example Session
Let’s walk through a full navigation session:
# 1. Check where you are
kronos@olympos:~$ pwd
/home/kronos
# 2. Go to the root directory
kronos@olympos:~$ cd /
kronos@olympos:/$ pwd
/
# 3. List the contents
kronos@olympos:/$ ls
bin dev home lib64 mnt proc run srv tmp var
boot etc lib media opt root sbin sys usr
# 4. Explore in detail
kronos@olympos:/$ ls -la
total 68
drwxr-xr-x 20 root root 4096 Jan 15 10:30 .
drwxr-xr-x 20 root root 4096 Jan 15 10:30 ..
lrwxrwxrwx 1 root root 7 Jan 15 10:30 bin -> usr/bin
drwxr-xr-x 4 root root 4096 Jan 15 10:30 boot
drwxr-xr-x 20 root root 3860 Jan 15 10:30 dev
drwxr-xr-x 120 root root 12288 Jan 15 10:30 etc
drwxr-xr-x 3 root root 4096 Jan 15 10:30 home
...
# 5. Go into /home
kronos@olympos:/$ cd home
kronos@olympos:/home$ ls
kronos anotheruser
# 6. Go into your user directory
kronos@olympos:/home$ cd kronos
kronos@olympos:~$ pwd
/home/kronos
# 7. Create and navigate into a subdirectory
kronos@olympos:~$ cd test
kronos@olympos:~/test$ pwd
/home/kronos/test
# 8. Move up one level
kronos@olympos:~/test$ cd ..
kronos@olympos:~$ pwd
/home/kronos
# 9. Move up two levels with a single command
kronos@olympos:~$ cd ../..
kronos@olympos:/$ pwd
/
# 10. Go home and back
kronos@olympos:/$ cd
kronos@olympos:~$ pwd
/home/kronos
kronos@olympos:~$ cd /etc
kronos@olympos:/etc$ cd -
kronos@olympos:~$ pwd
/home/kronos
Quick Reference
Navigation Commands
| Command | Description |
|---|---|
pwd | Print working directory |
cd <dir> | Change to <dir> |
cd or cd ~ | Change to home directory |
cd .. | Move up one level |
cd ../.. | Move up two levels |
cd / | Move to root |
cd - | Move to previous directory |
cd ~user | Move to another user’s home |
ls | List files in current directory |
ls -la | List with details + hidden files |
Special Path Symbols
| Symbol | Meaning | Example |
|---|---|---|
/ | Root directory | cd / |
~ | Home directory | cd ~/Documents |
. | Current directory | ./script.sh |
.. | Parent directory | cd .. |
- | Previous directory | cd - |
~user | Another user’s home | cd ~alice |
ls -la Output Breakdown
drwxr-xr-x 20 root root 4096 Jan 15 10:30 etc
โโโโโฌโโโโ โ โ โ โ โ โ
โ โ โ โ โ โ โ โโโ Name
โ โ โ โ โ โ โโโโโโโโโโโโโโโ Modified time
โ โ โ โ โ โโโโโโโโโโโโโโโโโโโโโ Size (bytes)
โ โ โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโ Group
โ โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ Owner
โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ Link count
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ Permissions
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ File type (d=dir)
Best Practices
โ Do This:
# Always check where you are before navigating
pwd
# Use Tab to auto-complete directory names
cd Doc[Tab ] # Completes to Documents
# Use cd - to toggle between two directories
cd /var/log
cd ~
cd - # Back to /var/log
# Use ls -la to see hidden files (starting with .)
ls -la # Shows .bashrc, .config, etc.
# Use ~ for home to avoid typing long paths
cd ~/Documents/projects
โ Don’t Do This:
# Don't use absolute paths when relative works
cd /home/kronos/Documents # Use: cd ~/Documents
# Don't forget where you started
cd /etc
# ... 20 commands later ...
# Where was I? Use: cd - (if you haven't navigated elsewhere)
# Don't confuse .. and .
cd . # Goes nowhere (current dir)
cd .. # Goes up one level โ that's what you want
# Don't type paths manually โ use Tab
cd /usr/loc[Tab ] # Completes to /usr/local
Common Pitfalls
| Pitfall | Problem | Solution |
|---|---|---|
Forgetting pwd | Lost in the filesystem | Run pwd often |
Confusing .. and . | Wrong navigation | .. = parent, . = current |
Not using Tab | Typing errors | Use Tab to autocomplete |
| Absolute paths everywhere | Longer to type | Use relative paths + ~ |
Forgetting cd - | Can’t get back | Use it to toggle directories |
Visual Reference
Filesystem Hierarchy:
/
โโโ bin/ โ Essential commands
โโโ etc/ โ Config files
โโโ home/ โ User directories
โ โโโ kronos/ โ Your home (~)
โ โ โโโ Documents/
โ โ โโโ Downloads/
โ โ โโโ test/ โ You are here
โ โโโ alice/
โโโ tmp/ โ Temporary files
โโโ usr/ โ Programs
โโโ var/ โ Logs and data
Navigation shortcuts:
cd / โ Root
cd ~ โ Home
cd .. โ Parent
cd - โ Previous
cd test โ Into "test"
pwd โ Where am I?
Summary
| Concept | Description |
|---|---|
Root (/) | Top of the filesystem tree |
Home (~) | Your personal directory (/home/kronos) |
pwd | Shows where you are |
cd | Changes directory |
ls | Lists files |
., .., - | Current, parent, previous |
Remember: The filesystem is a tree. You’re always “somewhere” in that tree. Use pwd to confirm, cd to move, and ls to see what’s around you. And use Tab โ it will save you from typos and make you faster!
Stop using slow, ad-bloated tool sites! ๐คฎ
๐ Search “KandZ Tools” on Google to use many professional utilities for free.
KandZ.me is the ultimate minimalist hub for:
โ
Finance (Mortgage, Interest, Inflation)
โ
Tech (Base64, JSON, Dev Suite, IP)
โ
Health (BMI, BMR, TDEE)
โ
Productivity (Timer, Workspace, QR)
โก๏ธ Fast & Private
๐ No data leaves your device
๐ 100% Free
๐ Use it now: https://tools.kandz.me
๐ Bookmark itโyouโll need it later!