- Everything is a File
- The FHS (Filesystem Hierarchy Standard)
- Root Directory /
- Directory Deep Dive
- Special Filesystems
- File Types in Linux
- Absolute vs Relative Paths
- Practice Exercises
One of the most important Linux philosophies:
"On a Linux system, everything is a file. If something is not a file, it is a process."
This means:
- Regular files β files
- Directories β special files
- Hard drives β files (
/dev/sda) - USB devices β files (
/dev/usb) - Network sockets β files
- Running processes β files (in
/proc) - Even your keyboard and screen β files (
/dev/stdin,/dev/stdout)
The FHS defines the standard directory structure for Linux systems.
/ β Root of everything
βββ bin/ β Essential user binaries
βββ boot/ β Boot loader files, kernel
βββ dev/ β Device files
βββ etc/ β System configuration files
βββ home/ β User home directories
β βββ sovon/
β βββ alice/
βββ lib/ β Shared libraries
βββ lib64/ β 64-bit shared libraries
βββ media/ β Mount points for removable media
βββ mnt/ β Temporary mount points
βββ opt/ β Optional/third-party software
βββ proc/ β Virtual filesystem for processes
βββ root/ β Root user's home directory
βββ run/ β Runtime data
βββ sbin/ β System binaries (admin commands)
βββ srv/ β Service data
βββ sys/ β Virtual filesystem for hardware
βββ tmp/ β Temporary files (cleared on reboot)
βββ usr/ β User programs & data (read-only)
β βββ bin/
β βββ lib/
β βββ local/
β βββ share/
βββ var/ β Variable data (logs, mail, spool)
βββ log/
βββ cache/
βββ tmp/
The / (slash) is the top-level directory. Everything in Linux exists under /.
π Analogy: If your Linux system were a building,
/would be the ground floor lobby. Every room (directory) and every item (file) in the building is accessed from here.
β οΈ Warning:/(root directory) β/root(root user's home directory). Don't confuse them!
Contains commands that all users need, even in single-user mode.
ls /bin
# Contains: ls, cp, mv, rm, cat, grep, bash, echo, mount ...π On modern systems,
/binis often a symlink to/usr/bin.
Contains everything needed to start the system.
ls /boot
# vmlinuz-6.8.0-xx β The Linux kernel
# initrd.img-6.8.0-xx β Initial ramdisk
# grub/ β GRUB bootloader config
β οΈ Do NOT delete files in/bootunless you know exactly what you're doing.
Everything is a file β even hardware devices.
ls /dev
# sda β First hard drive
# sda1 β First partition of sda
# sdb β Second hard drive (or USB)
# null β Black hole (discards all data)
# zero β Infinite stream of zeros
# random β Random number generator
# urandom β Faster random generator
# tty β Terminal devices
# stdin β Standard input (keyboard)
# stdout β Standard output (screen)
# stderr β Standard error (screen)# Useful /dev tricks
echo "Gone forever" > /dev/null # Discard output
dd if=/dev/zero bs=1M count=100 of=testfile # Create a 100MB file of zeros
cat /dev/urandom | head -c 32 | base64 # Generate random stringAll system-wide configuration lives here. This is one of the most important directories.
ls /etc
# passwd β User account information
# shadow β Encrypted passwords
# group β Group information
# hostname β System hostname
# hosts β Static hostname to IP mapping
# fstab β Filesystem mount table
# sudoers β Sudo permissions
# ssh/ β SSH configuration
# apt/ β APT package manager config
# cron.d/ β Cron job configurations
# systemd/ β Systemd configuration
# nginx/ β Nginx web server config (if installed)# Peek at common config files
cat /etc/hostname # Your computer's name
cat /etc/os-release # Distro information
head -5 /etc/passwd # First 5 user accountsπ "etc" originally stood for "et cetera" but is now treated as "Editable Text Configuration."
Each user gets their own directory under /home.
/home/
βββ sovon/ β Your stuff
β βββ Desktop/
β βββ Documents/
β βββ Downloads/
β βββ .bashrc β Bash configuration (hidden)
β βββ .ssh/ β SSH keys (hidden)
β βββ .config/ β App settings (hidden)
βββ alice/ β Another user's stuff# The ~ shortcut always refers to YOUR home directory
echo ~ # /home/sovon
echo ~alice # /home/alice
# Important dotfiles in your home
cat ~/.bashrc # Bash shell configuration
cat ~/.profile # Login shell configuration
ls ~/.ssh/ # SSH keys and configA virtual filesystem β files here don't exist on disk. The kernel generates them on-the-fly.
ls /proc
# 1/ β Process with PID 1 (systemd/init)
# 1234/ β Process with PID 1234
# cpuinfo β CPU information
# meminfo β Memory information
# version β Kernel version
# uptime β System uptime
# loadavg β System load averages
# Useful examples
cat /proc/cpuinfo # Detailed CPU info
cat /proc/meminfo # Memory details
cat /proc/version # Kernel version string
cat /proc/uptime # Uptime in seconds
cat /proc/loadavg # Load averages
cat /proc/partitions # Disk partitionsData that changes frequently during normal operation.
/var/
βββ log/ β System logs
β βββ syslog
β βββ auth.log
β βββ kern.log
β βββ apt/
βββ cache/ β Application cache
β βββ apt/ β Downloaded .deb packages
βββ mail/ β User mail
βββ spool/ β Print and mail queues
βββ tmp/ β Temporary files (survives reboot)
βββ www/ β Web server files (Apache/Nginx)# Check recent system logs
sudo tail -20 /var/log/syslog
# See authentication logs
sudo tail -20 /var/log/auth.log
# Check disk usage of /var
du -sh /var/*# Anyone can write here. Files are deleted on reboot.
echo "temporary data" > /tmp/mytemp.txt
ls -la /tmp
# Check the sticky bit (the 't' at the end)
ls -ld /tmp
# drwxrwxrwt β 't' means only the owner can delete their own filesContains the majority of user-facing programs and data. Treated as read-only.
/usr/
βββ bin/ β Most user commands (ls, grep, vim, python, etc.)
βββ sbin/ β Non-essential system commands
βββ lib/ β Libraries for /usr/bin and /usr/sbin
βββ local/ β Locally installed software (compiled from source)
β βββ bin/
β βββ lib/
β βββ share/
βββ share/ β Architecture-independent data (man pages, icons)
β βββ man/ β Manual pages
β βββ doc/ β Documentation
β βββ icons/ β System icons
βββ include/ β C/C++ header filesThird-party software that doesn't follow the standard /usr layout.
/opt/
βββ google/chrome/ β Google Chrome
βββ discord/ β Discord
βββ lampp/ β XAMPP web stackThese don't exist on disk β the kernel creates them in memory.
| Filesystem | Purpose | Example |
|---|---|---|
/proc |
Process and kernel info | /proc/cpuinfo, /proc/1/status |
/sys |
Hardware and driver info | /sys/class/net/, /sys/block/sda/ |
# Find your network interfaces
ls /sys/class/net/
# Check battery status (laptops)
cat /sys/class/power_supply/BAT0/capacity
# Check disk scheduler
cat /sys/block/sda/queue/schedulerLinux has 7 file types, identified by the first character in ls -l output:
| Symbol | Type | Description |
|---|---|---|
- |
Regular file | Text files, binaries, images |
d |
Directory | Contains other files |
l |
Symbolic link | Pointer to another file |
c |
Character device | Serial data (keyboard, terminal) |
b |
Block device | Block data (hard drives) |
s |
Socket | Inter-process communication |
p |
Named pipe (FIFO) | Inter-process communication |
# Identify file type
file /bin/bash # ELF 64-bit executable
file /etc/passwd # ASCII text
file /dev/sda # block special
# Find all symlinks in /usr/bin
find /usr/bin -type l | head -10| Type | Starts With | Example | Meaning |
|---|---|---|---|
| Absolute | / |
/home/sovon/Documents |
Full path from root |
| Relative | Anything else | Documents or ./Documents |
Relative to current directory |
| Symbol | Meaning |
|---|---|
/ |
Root directory |
~ |
Home directory |
. |
Current directory |
.. |
Parent directory |
- |
Previous directory (for cd) |
# These are equivalent (if you're in /home/sovon):
cd /home/sovon/Documents # Absolute
cd ~/Documents # Using ~
cd Documents # Relative
cd ./Documents # Relative (explicit)- Explore: Run
ls /and identify each directory's purpose - Config Files: Read
/etc/os-releaseβ what distro are you running? - Processes: Run
ls /procand find your shell's PID withecho $$, thenls /proc/$$ - Hardware: Read
/proc/cpuinfoβ how many CPU cores do you have? - Memory: Read
/proc/meminfoβ how much total RAM do you have? - Devices: List
/devβ can you find your hard drive device? - Logs: Run
sudo tail -10 /var/log/syslogβ what's the latest log entry? - File Types: Run
file /bin/bash /etc/passwd /dev/nullβ what types are they?
β Previous: Terminal Basics Β· π Home Β· Next: File & Directory Operations β