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
| Directory | Contents | Why It Matters |
|---|---|---|
| / | Root of the entire file system | Everything starts here |
| /home | User home folders (/home/alice, /home/bob) | Users' personal files; protect these |
| /etc | System configuration files | passwd, shadow, group, fstab โ critical security files |
| /boot | Kernel and bootloader files | Don't modify unless you're an expert |
| /var/log | System log files | auth.log, syslog โ investigate attacks here |
| /tmp | Temporary files; world-writable | Malware often drops files here |
| /usr/bin | Most user programs and commands | ls, cat, nano, etc. |
| /sbin /usr/sbin | System administration commands | adduser, ifconfig, service |
Essential Navigation Commands
bash
pwd # Print Working Directory โ where am I?ls # List files in current directoryls -la # Long format (-l) + show hidden files (-a)cd /home/cyberpatriot # Change to absolute pathcd Documents # Change to relative path (sub-folder)cd .. # Go up one directorycd ~ # Go to your home directorycd - # Go back to previous directoryAbsolute 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 filecat file1 file2 # Display multiple files concatenatedless /var/log/auth.log # View large file with scroll (q to quit)grep 'Failed' /var/log/auth.log # Search for text in a filecp source dest # Copy filemv source dest # Move or rename filerm filename # Delete file (permanent โ no Recycle Bin!)rm -rf directory/ # Delete directory and all contents (use carefully!)touch newfile.txt # Create empty filemkdir newdir # Create directoryman 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?
๐ฎ Practice what you learned
โญ 0 XP๐ฅ 0 days