Linux Directory Structure
Linux follows a standard filesystem hierarchy where every file and directory starts from the root directory:
/
This structure is called the:
Filesystem Hierarchy Standard (FHS)
Root Directory /
The top-level directory in Linux.
Everything exists under:
/
Example:
/home
/etc
/var
/usr
Linux Directory Tree
/
├── bin
├── boot
├── dev
├── etc
├── home
├── lib
├── media
├── mnt
├── opt
├── proc
├── root
├── run
├── sbin
├── srv
├── sys
├── tmp
├── usr
└── var
Important Linux Directories
1. /bin
Meaning
Essential user binaries (commands).
Contains basic commands required for system operation.
Examples
/bin/ls
/bin/cp
/bin/mv
/bin/bash
Real-World Usage
Commands available even in recovery mode.
2. /sbin
Meaning
System binaries.
Contains administrative commands mainly used by root user.
Examples
/sbin/reboot
/sbin/fsck
/sbin/ip
Used For
- System repair
- Networking
- Boot management
3. /boot
Meaning
Boot-related files.
Contains:
- Linux kernel
- Bootloader files
- initramfs
Examples
/boot/vmlinuz
/boot/grub
Real-World Importance
Critical for system startup.
4. /dev
Meaning
Device files.
Linux treats hardware devices as files.
Examples
/dev/sda
/dev/null
/dev/tty
Important Devices
| Device | Purpose |
|---|---|
| /dev/sda | Hard disk |
| /dev/null | Discard output |
| /dev/random | Random generator |
Real-World Usage
Redirect Output
command > /dev/null
5. /etc
Meaning
System configuration files.
One of the most important directories.
Examples
/etc/passwd
/etc/hosts
/etc/nginx/
/etc/ssh/
Real-World Usage
Edit SSH Config
vim /etc/ssh/sshd_config
6. /home
Meaning
User home directories.
Example
/home/aryan
/home/user1
Contains
- Documents
- Downloads
- User configs
- Scripts
Hidden Files Example
/home/user/.bashrc
7. /root
Meaning
Home directory of root user.
Example
/root
Difference
| Directory | Purpose |
|---|---|
| /home/user | Normal user |
| /root | Root administrator |
8. /lib and /lib64
Meaning
Shared libraries required by programs.
Similar to DLL files in Windows.
Examples
/lib/modules
/lib64/libc.so
Real-World Importance
Programs depend on these libraries.
9. /usr
Meaning
User applications and utilities.
Largest directory in many systems.
Important Subdirectories
| Path | Purpose |
|---|---|
| /usr/bin | User commands |
| /usr/sbin | Admin commands |
| /usr/lib | Libraries |
| /usr/share | Shared data |
Examples
/usr/bin/python
/usr/bin/docker
10. /var
Meaning
Variable data files.
Data changes frequently here.
Important Subdirectories
| Path | Purpose |
|---|---|
| /var/log | Logs |
| /var/cache | Cache |
| /var/www | Web files |
| /var/spool | Queues |
Real-World Usage
View Logs
cd /var/log
Examples
/var/log/syslog
/var/log/nginx/
11. /tmp
Meaning
Temporary files.
Characteristics
- Temporary storage
- Often cleared on reboot
Example
/tmp/install.tmp
Real-World Usage
Scripts store temporary data here.
12. /proc
Meaning
Virtual filesystem containing process and kernel information.
Examples
/proc/cpuinfo
/proc/meminfo
Real-World Usage
Check CPU Info
cat /proc/cpuinfo
13. /sys
Meaning
Kernel and hardware information.
Used for:
- Device management
- Kernel tuning
Example
/sys/class
/sys/devices
14. /opt
Meaning
Optional third-party software.
Examples
/opt/google
/opt/app
Real-World Usage
Custom applications installed here.
15. /mnt
Meaning
Temporary mount points.
Example
/mnt/backup
Used For
- Mount disks
- Attach storage
- Temporary filesystems
16. /media
Meaning
Removable media devices.
Examples
/media/usb
/media/cdrom
Used For
USB drives and external devices.
17. /run
Meaning
Runtime process data.
Contains temporary system information.
Examples
/run/docker.sock
/run/systemd/
Real-World Usage
Docker socket communication.
18. /srv
Meaning
Service data provided by system.
Examples
/srv/www
/srv/ftp
Linux Directory Quick Summary
| Directory | Purpose |
|---|---|
| / | Root filesystem |
| /bin | Essential commands |
| /sbin | System commands |
| /boot | Boot files |
| /dev | Device files |
| /etc | Configurations |
| /home | User directories |
| /root | Root user home |
| /lib | Libraries |
| /usr | Applications |
| /var | Logs and variable data |
| /tmp | Temporary files |
| /proc | Process info |
| /sys | Kernel info |
| /opt | Optional software |
| /mnt | Temporary mounts |
| /media | External media |
| /run | Runtime data |
| /srv | Service data |
Top comments (0)