Chapter 3.2 - Directory Structure
Learning Objectives
By the end of this chapter, you will be able to:
- Understand the detailed structure of Linux directories
- Identify the role of each main directory
- Navigate the system effectively
- Find configuration files and data
Main Directories
/ (Root)
Starting point of the entire hierarchy. All other directories are under /.
/bin - Essential Binaries
Essential commands for all users:
ls,cp,mv,rmcat,grep,findbash,sh
Characteristics:
- Accessible to all
- Necessary for booting
- Basic commands
/sbin - System Binaries
Commands for system administration:
fdisk,mkfsifconfig,iptablessystemctl,init
Characteristics:
- Generally requires root
- System administration
- Maintenance
/etc - Configuration
System configuration files:
/etc/passwd: Users/etc/group: Groups/etc/hosts: Local name resolution/etc/fstab: Mounted file systems/etc/ssh/: SSH configuration
Characteristics:
- Editable text configuration
- Modifications often require root
- Backup before modification
/home - Users
Personal directories for users:
/home/user1//home/user2/- Each user has their own directory
Characteristics:
- Personal space
- User permissions
- Personal files
/usr - User Programs
Programs and libraries:
/usr/bin: User binaries/usr/lib: Libraries/usr/share: Shared data/usr/local: Local programs
Characteristics:
- Non-essential programs
- Can be mounted read-only
- Large portion of software
/var - Variable Data
Data that changes during operation:
/var/log: System logs/var/cache: Cache/var/spool: Queues/var/tmp: Persistent temporary
Characteristics:
- Changing data
- Can grow quickly
- Monitor disk space
/tmp - Temporary
Temporary files:
- Accessible to all
- Generally cleared on reboot
- Broad permissions
/dev - Devices
Representations of devices:
/dev/sda,/dev/sdb: Disks/dev/tty: Terminals/dev/null: Bottomless pit/dev/random: Random
Characteristics:
- Interface to hardware
- Created dynamically
- Special (not normal files)
/proc - Kernel Interface
Information about processes and the system:
/proc/cpuinfo: CPU info/proc/meminfo: Memory info/proc/pid/: Process details
Characteristics:
- Virtual file system
- Real-time data
- Read-only (generally)
/sys - System Interface
System and hardware information:
/sys/class/: Device classes/sys/devices/: Devices- Interface to the kernel
Characteristics:
- Virtual file system
- Hardware information
- Hardware configuration
Practical Navigation
Finding Files
# Search for a file
find / -name "file.txt" 2>/dev/null
find /home -name "*.txt"
# Search by type
find / -type f -name "*.conf"
find / -type d -name "config"
# Search recently modified
find /var/log -mtime -1 # Last 24h
Viewing Size
# Directory sizes
du -sh /home/*
du -h --max-depth=1 /
# Disk space
df -h
df -h /home
Summary
In this chapter, you learned:
Main directories: /, /bin, /etc, /home, /usr, /var, /tmp
Configuration: /etc contains config files
Users: /home for personal directories
Programs: /usr for software
Variables: /var for changing data
Devices: /dev for hardware access
Kernel: /proc and /sys for system info
Next Steps
Chapter 3.3: Navigation and Basic Commands
Chapter 3.4: File Management
Chapter created on: December 2024