|

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
CommandDescription
cd /Move to the root directory
lsShow files and folders in the current directory
ls -laShow 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 ..
CommandDescription
pwdPrint Working Directory โ€” shows where you are
cd homeMove into the home directory
lsList contents of the current directory
cd testMove 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
  • pwd displays it โ€” like a “you are here” marker
  • /home is a path; its parent folder is the root /
  • /home/test is a path; test‘s parent is home, 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 -
CommandDescription
cdChanges to your home directory
cd ~Also changes to your home directory (~ = home)
cd ~anotherUserNameChanges to another user’s home directory
cd -Changes to the previous working directory

Detailed breakdown:

SyntaxMeaning
cdShortcut for cd ~ โ€” goes home
~Tilde โ€” shorthand for your home directory (e.g., /home/kronos)
~userTilde + 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

CommandDescription
pwdPrint 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 ~userMove to another user’s home
lsList files in current directory
ls -laList with details + hidden files

Special Path Symbols

SymbolMeaningExample
/Root directorycd /
~Home directorycd ~/Documents
.Current directory./script.sh
..Parent directorycd ..
-Previous directorycd -
~userAnother user’s homecd ~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

PitfallProblemSolution
Forgetting pwdLost in the filesystemRun pwd often
Confusing .. and .Wrong navigation.. = parent, . = current
Not using TabTyping errorsUse Tab to autocomplete
Absolute paths everywhereLonger to typeUse relative paths + ~
Forgetting cd -Can’t get backUse 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

ConceptDescription
Root (/)Top of the filesystem tree
Home (~)Your personal directory (/home/kronos)
pwdShows where you are
cdChanges directory
lsLists 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!