DEV Community

Kervie Sazon
Kervie Sazon

Posted on

Linux Fundamentals - Part 2: Understanding Directory Hierarchy

This post summarizes what I have learned about the most common Linux directories and how they are used in a typical system.

/ - Root Directory
The root directory is the starting point of a Linux filesystem.
All other directories and files are exist under this directory.

/bin - Binaries
The bin directory contains essential commands that are required for basic system operations.
Some examples:
ls
cd
cp
mv
rm

/dev - Device Files
This directory only contains special files, including those relating to the devices. These are virtual files, not physically on the disk.

/dev/null
Enter fullscreen mode Exit fullscreen mode

This line of code can be sent to destroy any file or string.

/dev/zero
Enter fullscreen mode Exit fullscreen mode

This line of code contains an infinite sequence of 0.

/dev/random
Enter fullscreen mode Exit fullscreen mode

This line of code contains an infinite sequence of random values.

/etc - Configuration Files
This directory contains the core configuration files of the system, use primarily by the administrator and services, such as the password file and networking files.

/usr - User System Resources
This directory contains most installed software and user-level programs.
Common subdirectories include:
/usr/bin - contains basic user commands.
/usr/sbin - contains additional commands for the administrator.
/usr/lib - contains the system libraries.
/usr/share - contains documentation manual pages.

/home - User Home Directories
This directory contains personal directories for regular users.
Example:

/home/Downloads
Enter fullscreen mode Exit fullscreen mode

/lib - Shared Libraries
These directories store shared libraries required by system binaries in /bin and /sbin.
They are essential for the system to boot and function properly.

/sbin - System Administration Command
This directory stores system administration commands, mainly used by the root user.
These commands are related to system maintenance, startup, and recovery.
Examples:
reboot
shutdown
fsck

/tmp - Temporary Files
This directory is used for temporary files created by applications and users.
Files stored here are usually deleted automatically when the system restarts.

/var - Variable Data
This directory stores data that changes over time while the system is running.
Common Examples:
/var/log - System logs
/var/cache - Cache files
/var/spool- Spool files
This directory is important for troubleshooting and system monitoring.

/proc - Process Information
The /proc directory is a virtual filesystem that provides information about running processes and the kernel.
Example:

/proc/cpuinfo
Enter fullscreen mode Exit fullscreen mode

It is commonly used to inspect system status and performance.

/opt - Optional Software
This directory is used for optional or third-party software that is installed outside the standard system directories.

/mnt & /media - Mount Points
These directories are used to mount filesystems:
/mnt is typically used for temporary or manual mounts.
/media is used for automatically mounted removable devices such as USB drives.

/srv - Service Data
This directory contains data for services provided by the system. For example, if you run a HTTP server, it’s a good practice to store the website data in the /srv directory.

Learning the Linux directory hierarchy helped me understand how Linux organizes system files, user data, and configuration.
For beginners like me, this knowledge is essential for Navigating the filesystem and Understanding system behavior.
As I continue learning Linux, having a clear mental model of the directory structure makes troubleshooting and system management much easier.

Tomorrow, I will study How to edit files in Linux using nano and vim to better understand how configuration and system files are managed.

Top comments (0)