Table of contents
Introduction
Linux File Hierarchy Structure (FHS) : It's like a map that tells us where everything goes in a Linux computer.
Maintained by Linux Foundation : The FHS is managed by the Linux Foundation, which makes sure everything stays organized.
Root Directory (/) : This is the main place where all files and folders start from, no matter where they are stored.
Universal Usage : Most of these directories are used the same way in all UNIX systems, but the FHS gives specific details for Linux systems.
/ (root) :
The computer system's root directory serves as the head of every folder.
Beginning with this root directory, which is simply a forward slash (/), all files and folders are created.
This directory is only directly editable by the root user, who is the boss.
The root directory (/) is not where the administrator stores private files.
/root
is the boss's personal folder; it is not the same as the root directory (/).
/home :
Each user on a computer system has a personalized place thanks to home directories.
Users save their own files, preferences, and other private information in their home directories.
Every user can freely handle their files in their own home directory, such as
/home/chandra
or/home/prakash
.Home directories limit access to each user's files and preferences, protecting privacy and security.
/usr :
This level includes the majority of user utilities and apps as well as read-only user data.
For programs at the secondary level, it contains source code, libraries, documentation, and binaries.
Key directories for user programs include :
/usr/bin
: Holds binary files for user programs likeat
,awk
,cc
,less
, andscp
./usr/sbin
: Contains binary files for system administrators such asatd
,cron
,sshd
,useradd
, anduserdel
./usr/lib
: Stores libraries for programs in/usr/bin
and/usr/sbin
.
User-installed programs are typically found in:
/usr/local
: This directory houses user-installed programs, typically installed from source code. For example, Apache web server installations go under/usr/local/apache2
.
Key system resources, such as header files, the Linux kernel code, and documentation, can be found in:
/usr/src
: Documentation, header files, and Linux kernel sources are all contained in this directory.
/etc :
These are unique files that impact the entire system and are unique to the computer they are on.
They contain crucial configurations that are required by every installed program on the system.
Scripts that manage how apps launch and terminate at computer startup and shutdown are also located in this directory.
Some examples include
/etc/resolv.conf
, which stores DNS server settings, and/etc/logrotate.conf
, which configures log rotation settings.
/root :
The root user, who has complete authority over the system, keeps this directory private.
This directory's contents can only be accessed and changed by the root user.
It functions as a secret space where the root user stores and manages sensitive system configurations and files.
It is not the same as the top-level directory for the entire file system, the root directory (/).
/opt :
These are additional software applications that you may or may not need, but that you may like to install for particular uses or purposes.
Several apps that are not part of the operating system are stored in this directory and come from different sources.
Installing add-on programs should take place in a subdirectory of
/opt/
or directly under the/opt/
directory. They remain divided from the main system files as a result.
/lib :
Important libraries that are required for the correct operation of programs in
/bin/
and/sbin/
are kept in this directory.This directory contains libraries that are essential to running programs from
/bin/
and/sbin/
.Library filenames typically start with "ld*" or "lib*.so.*".
/boot :
The files in this directory are necessary for the operating system to boot up.
These are the files, such as kernels and initial RAM disk (.initrd) files, required by the boot loader.
Here are some important files: GRUB, vmlinux, and kernel initrd.
Bootloader :
A bootloader is a brief software application that launches with your machine. It is the first application to launch when the system boots up.
Locating and loading the operating system into memory is its primary duty. It finds the kernel and necessary files for the operating system to boot up.
In addition, the bootloader manages hardware initialization, making sure that all necessary hardware parts are set up correctly before the operating system takes over.
A boot menu is provided by certain bootloaders, such GRUB (GRand Unified Bootloader). Users have freedom at starting by being able to select from a variety of operating systems or boot settings via this menu. Because it enables users to boot into several operating systems that are installed on the computer, GRUB is especially flexible.
Other bootloaders such as LILO, Syslinux, rEFInd, and UEFI exist in addition to GRUB. With a range of features and functionalities, each responds to particular needs and tastes.
/sbin :
The system binaries included in this directory are essential for system maintenance and operation.
Just like the
/bin
directory,/sbin
also stores binary executable files.System administrators usually use these commands to perform routine maintenance on the system.
Some examples of commands found in this directory include
fsck
,init
,shutdown
,reboot
,fdisk
,ifconfig
.
/bin :
The command binaries required for system operation, including those needed in single-user mode, are stored in this directory.
Many common Linux commands, such as
cat
,ls
, andcp
are stored here. These commands are frequently used for various system tasks and operations.Commands located in
/bin
are accessible to all users of the system. Examples includeps
,ping
,grep
, andcp
, which are used by all users for different purposes.
/var :
The system uses changing data files stored in this directory while it operates.
It is the location where the system stores logs, temporary data, and other items that are subject to frequent changes while the system is operating.
Files such as system logs, pending emails, and temporary files can be found inside
/var
.Users and system applications save and retrieve data via
/var
. Maintaining this directory correctly is essential to the system's functionality.
/mnt :
Users can temporarily mount network sites or external devices in this directory.
It acts as a point of connection between the system and devices such as network shares, USB drives, and external hard drives.
In order to access the contents of devices like USB drives or network folders, users frequently mount them to /mnt.
It serves as a temporary location for external data access. The files are removed from
/mnt
whenever the device or location is unmounted.
/media :
The system automatically mounts external devices, such as optical discs and USB drives, in this directory.
It's where, when you add in devices like USB drives or CDs, the system connects automatically and displays content from those sources.
The files on a USB drive or CD will appear under
/media
so you can quickly access them when you plug them in.It serves as a space for short-term external device storage. The files vanish from
/media
as soon as the device is removed.
/tmp :
Temporary files that are required while programs are running are kept in this directory.
It functions similarly to a short-term storage space where programs can store files they require temporarily.
Programs may utilize the
/tmp
directory to hold temporary files while they are operating, such as while processing data or downloading files.To prevent permanently filling up your storage, files in
/tmp
are typically automatically erased when your computer restarts or after a predetermined period of time.
Conclusion
Files are easily found and managed in Linux thanks to its clean file organization into directories.
Various directories perform different functions, such as storing temporary files (
/tmp
), storing changing data (/var
), or containing critical programs (/bin
).Users can add their own stuff in places like
/usr/local
or connect external devices in/mnt
and/media
, making Linux work just how they want.directories like
/home
give everyone their own space to keep their files safe, while/boot
has what's needed to start up the system smoothly.It's crucial to take care of folders like
/var
and/tmp
to keep the system stable and secure, as they handle important data and temporary files. Regular cleanup and following good practices help keep Linux running well.