Linux File System

Introduction
Linux is an operating software based on the Linux kernel. It is open source, so it is maintained by the global community. It was created by Linus Torvalds in 1991.
This operating system is consist of file and folder which has many responsible action to perform. It is called as Linux File Hierarchy Structure or Filesystem Hierarchy Standard (FHS). It is maintained by Linux Foundation.
/ Root
/ Root (root directory) is the base point of linux file sturcture. So, no directory can exist above it.
It has many files and folders and nobody can make a change in those files and folders. Only root user has permission to do so.
Its main function is that every file and folders must start from the root directory.
Root /
Root / is the home folder. Its main function is to hold configuration files and data for the root user.
Role -
Installing and updating softwares which are system-wide binaries (/bin, /sbin).
Creating, deleting, and modifying other user accounts, including changing their passwords.
Running maintenance tools to fix a system in "single-user mode".
File Ownership/Permissions: Modifying, reading, writing, or deleting any file on the system, regardless of who owns it.
System Administration: Changing system-wide configuration files (often located in
/etc).
Purpose -
Separation of Duties: It separates daily, restricted user tasks (like editing documents) from risky administrative tasks (like modifying drivers or system kernels).
System Security and Integrity: By restricting access to vital system files to only the root user, it prevents accidental or malicious tampering by standard users.
BIN /
The /bin (binaries) directory contains many commands like cat, chmod, date, echo, kill, login, mkdir, rm, sh and binaries like ls, cp, mv.
Role -
- It holds binary files which are required by all users.
Purpose -
Standardization: It acts as a standard, known location for software executables.
Booting/Repair: It is typically available during the early stages of the boot process before other filesystems are mounted.
DEV /
The /dev directory contains all the device files. These files act as interface between hardware and software.
These files are of two types -
Block devices: e.g. - hard drives
Character devices: e.g. - microphones and speakers
ETC /
The /etc directory contains system-wide configuration file. It stands for 'Editable Text Configuration'.
It act as control panel by holding the settings that define how the system, services and applications behave.
Example - /etc/passwd
USR /
The /usr directory contains the majority of (multi-) user utilities and applications. It stores read only data which can be shared.
/usr/bin: Contains the vast majority of user commands and executable binaries (e.g.,
ls,cat,bash) that come with the distribution./usr/sbin: Contains non-essential system administration binaries (e.g., networking utilities).
/usr/lib: Stores libraries required by binaries in
/usr/binand/usr/sbin./usr/src: Contains source code, including kernel headers.
/usr/share: Holds architecture-independent data files that can be shared across different machine types (e.g., documentation, icons, fonts).
/usr/local: The dedicated area for system administrators to install software manually without overwriting system packages.
HOME /
The /home directory contains all personal files of every non-root user.
Role -
File Storage: It stores user documents, downloads, desktop files, pictures, and videos.
Settings Storage: It holds personal configuration files and directories, typically hidden files known as "dotfiles" (e.g.,
.bashrc,.config/).
LIB /
The /lib directory contains library (folders and applications) and kernal modules which can be shared during runtime or boot the system.
SBIN /
The /sbin directory contains binary files which are used by the administrator for system maintainance purpose.
Role-
Administrative Tasks: It includes commands for system-level configuration rather than everyday user tasks.
Startup/Shutdown Control: It contains tools to power off, reboot, and manage system runlevels, such as
shutdownandreboot.
TMP /
The /tmp directory contains all the files created by the system and users which are deleted when the system is rebooted.
It holds ephemeral data that needs to exist only while a program is running, such as temporary copies of files being edited, extracted archives, or database locks.
VAR /
The /var directory contains variable data files which are dynamic, transient, or constantly updated while the system is running.
/var/log: Stores system and application log files (e.g.,
syslog,auth.log,kern.log). This is perhaps the most critical part of/varfor troubleshooting./var/mail or /var/spool/mail: Contains user mailbox files.
/var/spool: Queued tasks, such as printer jobs or outgoing email queues.
/var/www: Commonly used as the root directory for web server files (Apache/Nginx).
/var/lib: Stores persistent state information that changes as applications run (e.g., database files from MySQL/PostgreSQL).
/var/cache: Application cache data, which can be deleted but speeds up future operations.
/var/tmp: Temporary files that are preserved between system reboots (unlike
/tmp, which is often cleared).
BOOT /
The /boot directory contains all the bootloader files required for booting the system.
PROC /
The /proc directory contains information about system process. Each process is assigned a unique ID and represented as a directory inside /proc.
Example - Files like /proc/cpuinfo, /proc/meminfo, and /proc/stat provide live hardware and OS performance metrics.
OPT /
The /opt directory contains third-party softwares and packages which are not part of the default system installation.
Example - Google
SRV /
The /srv directory contains server specific services related data. It stands for service.
Example - /srv/cvs contains CVS related data.
MNT /
The /mnt directory contains temporary mount directory where system admins can mount filesystems. This is where their contents become accessible to the system.
MEDIA /
The /media directory contains directory for removable devices.
Example - /media/cdrom for CD-ROM, /media/usb for USB.
Difference between /mnt and /media directory
| Feature | /mnt |
/media |
|---|---|---|
| Purpose | Temporary, manual mounting. | Automated mounting of removable media. |
| User | System Administrator (root). | User-level mount (Desktop Environment). |
| Visibility | Rarely appears in file manager (Nautilus). | Appears in file manager left pane. |
| Usage | E.g., mount /dev/sdb1 /mnt/data |
E.g., USB sticks, CDs, external drives. |
Conclusion
Linux File System has hierarchical structure which is used to operate system and it makes the life of user easier. It is dynamic, fast and smooth.
Hence, having knowledge of all files and its directory will make your system to function good for
