Table of Contents#
- Root Directory (/)
- /bin and /sbin Directories
- /boot Directory
- /dev Directory
- /etc Directory
- /home Directory
- /lib and /lib64 Directories
- /media and /mnt Directories
- /opt Directory
- /proc Directory
- /root Directory
- /run Directory
- /srv Directory
- /sys Directory
- /tmp Directory
- /usr Directory
- /var Directory
1. Root Directory (/)#
The root directory is the top - level directory in the Linux file system. It contains all other directories and files. It's like the "base" of a tree, with everything else branching out from it.
2. /bin and /sbin Directories#
- /bin:
- This directory contains binary (executable) files that are essential for system operation and are available to all users. For example, common commands like
ls,cd,echoare located here. - Example Usage: When you type
lsin the terminal, the system looks for thelsbinary in/bin(or other relevant directories in thePATHvariable).
- This directory contains binary (executable) files that are essential for system operation and are available to all users. For example, common commands like
- /sbin:
- Holds system - administration binary files. These are usually only accessible to the root user. Commands like
shutdown,reboot,fdisk(for disk partitioning) are in/sbin. - Best Practice: Only use commands from
/sbinwhen you know what you're doing as they can have a significant impact on the system.
- Holds system - administration binary files. These are usually only accessible to the root user. Commands like
3. /boot Directory#
- Stores files necessary for booting the system, such as the Linux kernel (
vmlinuz), initial ramdisk images (initrdorinitramfs), and boot loader configuration files (e.g., GRUB configuration files). - Common Practice: Don't modify files in
/bootunless you are performing a system upgrade or customizing the boot process.
4. /dev Directory#
- Represents device files. In Linux, everything is a file, and devices (like hard drives, USB drives, printers) are accessed through special files in
/dev. For example,/dev/sdamight be the first hard disk, and/dev/ttyis the terminal device. - Example Usage: When you want to access a USB drive, the system will create a device file (e.g.,
/dev/sdb1for a partition on the USB drive) when it's plugged in.
5. /etc Directory#
- Contains configuration files for system and applications. This is a crucial directory. Files like
/etc/passwd(user account information),/etc/group(group information),/etc/network/interfaces(network configuration) are here. - Best Practice: Make backups of important configuration files before making changes. For example, before changing the network configuration in
/etc/network/interfaces, copy the original file.
6. /home Directory#
- Each user's home directory is located here. For example, if there is a user named
john, their home directory is/home/john. Users can store their personal files, documents, and configuration files (in hidden sub - directories like.bashrcfor shell configuration). - Common Practice: Encourage users to store their data in their home directories for better organization.
7. /lib and /lib64 Directories#
- /lib:
- Holds shared library files that are used by binaries in
/binand/sbin. These libraries provide functions that multiple programs can use. For example, the C library (libc.so).
- Holds shared library files that are used by binaries in
- /lib64:
- On 64 - bit systems, stores 64 - bit shared libraries.
8. /media and /mnt Directories#
- /media:
- Automatically mounts removable media (like CDs, DVDs, USB drives) when they are inserted. For example, a CD might be mounted at
/media/cdrom.
- Automatically mounts removable media (like CDs, DVDs, USB drives) when they are inserted. For example, a CD might be mounted at
- /mnt:
- Traditionally used for manual mounting of filesystems. You can mount a remote filesystem (e.g., via NFS) or an additional local partition here.
- Example Usage:
mount /dev/sdb1 /mnt/usb(mounts a USB drive partition to/mnt/usb).
9. /opt Directory#
- Intended for the installation of third - party software packages. Some applications may install their files here. For example, a proprietary software might be installed in
/opt/software_name. - Best Practice: Check the documentation of the software to see if it follows the FHS for installation in
/opt.
10. /proc Directory#
- A virtual filesystem that provides information about running processes and system resources. Files in
/procare not real files on disk but are generated on - the - fly. For example,/proc/cpuinfoshows CPU information, and/proc/meminfoshows memory information. - Example Usage:
cat /proc/cpuinfoto view CPU details.
11. /root Directory#
- The home directory of the root user. It contains configuration files specific to the root user and is separate from the regular user home directories in
/home.
12. /run Directory#
- Holds runtime files, such as process ID (PID) files. These files are created and removed as processes start and stop. For example, a web server might create a PID file in
/runwhen it starts.
13. /srv Directory#
- Used to store data for services provided by the system. For example, a web server might store its website data in
/srv/www.
14. /sys Directory#
- Another virtual filesystem that provides information about the system's hardware and device drivers. Similar to
/proc, but more focused on hardware - related information.
15. /tmp Directory#
- A temporary storage area. Files in
/tmpare usually deleted when the system is rebooted (although some configurations may change this). Applications use/tmpto store temporary files. For example, a text editor might save a temporary file here if the user hasn't saved the main file yet. - Best Practice: Don't rely on
/tmpfor long - term storage.
16. /usr Directory#
- Stands for "Unix Software Resource". It contains user - accessible programs, libraries, documentation, and more.
- /usr/bin: Holds user - level binary files (more than
/bin). - /usr/sbin: System administration binaries (more than
/sbin). - /usr/lib and /usr/lib64: Similar to
/liband/lib64but for a wider range of applications. - /usr/share: Stores shared data like man pages (in
/usr/share/man), fonts, and application - specific data. - /usr/src: Can hold source code, especially for the Linux kernel (if you are compiling a custom kernel).
- /usr/bin: Holds user - level binary files (more than
17. /var Directory#
- Holds variable data, such as log files (
/var/log), spool files (for printing, email), and cache files. Log files in/var/log(e.g.,/var/log/syslogwhich records system messages) are crucial for debugging. - Best Practice: Regularly check log files in
/var/logfor any error messages.
Reference#
- Linux File Hierarchy Standard (FHS) official documentation
- Various Linux system administration books and online tutorials.