Linux Fundamentals ยท 3.2

๐Ÿ“‚ Linux File System & Navigation

Finding your way around the command lineโฑ ~3 min

The Linux file system is a tree structure rooted at / (called 'root'). Everything โ€” files, devices, network connections โ€” appears as a node in this tree.

Important Directories

DirectoryContentsWhy It Matters
/Root of the entire file systemEverything starts here
/homeUser home folders (/home/alice, /home/bob)Users' personal files; protect these
/etcSystem configuration filespasswd, shadow, group, fstab โ€” critical security files
/bootKernel and bootloader filesDon't modify unless you're an expert
/var/logSystem log filesauth.log, syslog โ€” investigate attacks here
/tmpTemporary files; world-writableMalware often drops files here
/usr/binMost user programs and commandsls, cat, nano, etc.
/sbin /usr/sbinSystem administration commandsadduser, ifconfig, service

Essential Navigation Commands

bash
pwd # Print Working Directory โ€” where am I?
ls # List files in current directory
ls -la # Long format (-l) + show hidden files (-a)
cd /home/cyberpatriot # Change to absolute path
cd Documents # Change to relative path (sub-folder)
cd .. # Go up one directory
cd ~ # Go to your home directory
cd - # Go back to previous directory

Absolute vs. Relative Paths

  • โ€ขAbsolute path โ€” always starts with / and works from anywhere: /home/alice/Documents/report.txt
  • โ€ขRelative path โ€” starts from your current directory: Documents/report.txt (only works if you're in /home/alice/)
  • โ€ข. = current directory, .. = parent directory

Essential File Commands

bash
cat /etc/passwd # Display contents of a file
cat file1 file2 # Display multiple files concatenated
less /var/log/auth.log # View large file with scroll (q to quit)
grep 'Failed' /var/log/auth.log # Search for text in a file
cp source dest # Copy file
mv source dest # Move or rename file
rm filename # Delete file (permanent โ€” no Recycle Bin!)
rm -rf directory/ # Delete directory and all contents (use carefully!)
touch newfile.txt # Create empty file
mkdir newdir # Create directory
man ls # Open manual for any command (q to quit)
ls --help # Quick help for a command
โš  Warningrm -rf has no undo. There is no Recycle Bin on the command line. Always double-check your path before running rm commands, especially as root/sudo.
๐Ÿง Quick Checkfirst try = +5 XP

Which directory holds Linux system configuration files?

โญ 0 XP๐Ÿ”ฅ 0 days