Skip to main content

Important Directories in Linux File System

Linux organizes its file system in a hierarchical structure, starting from the root directory (/). Each directory serves a specific purpose, ensuring a clear and organized layout. Here’s an overview of the most important directories in the Linux file system:


Important Directories in Linux

  1. / (Root Directory)

    • The topmost directory in the Linux file system.
    • All other directories and files stem from this directory.
    • Accessible only by the root user for critical modifications.
  2. /bin (Binary Files)

    • Contains essential binary executables used by all users.
    • Examples include common commands like ls, cat, cp, mv, etc.
    • These binaries are available even in single-user mode (emergency mode).
  3. /boot (Boot Loader Files)

    • Stores files needed to boot the operating system, including:
      • Kernel files (vmlinuz).
      • Boot loader configurations (e.g., GRUB files).
    • Example: /boot/grub/grub.cfg.
  4. /dev (Device Files)

    • Contains device files representing hardware devices (e.g., disks, printers, terminals).
    • Examples:
      • /dev/sda: First hard drive.
      • /dev/tty: Terminal devices.
      • /dev/null: Null device for discarding output.
  5. /etc (Configuration Files)

    • Stores system-wide configuration files and scripts.
    • Examples:
      • /etc/passwd: User account details.
      • /etc/fstab: Filesystem mount points.
      • /etc/hosts: IP-to-hostname mappings.
  6. /home (User Home Directories)

    • Contains the personal directories for each user.
    • Example:
      • /home/alice: Home directory for the user alice.
    • Users store their personal files, configurations, and documents here.
  7. /lib (Shared Libraries)

    • Contains essential shared libraries required by programs in /bin and /sbin.
    • Example: /lib/libc.so.6.
  8. /media (Removable Media)

    • Mount point for removable media, such as USB drives, CDs, and DVDs.
    • Example: /media/usb.
  9. /mnt (Temporary Mount Points)

    • Temporary mount point for filesystems during manual mounting.
    • Commonly used for system administrators to mount disks temporarily.
  10. /opt (Optional Software)

    • Used to install third-party or optional software packages.
    • Example: /opt/vmware for VMware-related files.
  11. /proc (Process Information)

    • Virtual filesystem providing information about running processes.
    • Examples:
      • /proc/cpuinfo: CPU details.
      • /proc/meminfo: Memory usage.
      • /proc/[pid]: Information about a specific process.
  12. /root (Root User's Home Directory)

    • Home directory for the root user (superuser).
    • Different from / (root directory).
  13. /run (Runtime Data)

    • Stores runtime data for system processes since boot time.
    • Examples: Process IDs, sockets, and other transient files.
  14. /sbin (System Binaries)

    • Contains essential system binaries for administrative tasks.
    • Examples:
      • ifconfig: Network configuration.
      • fsck: Filesystem check.
  15. /srv (Service Data)

    • Stores data for services provided by the system (e.g., web servers, FTP).
    • Example: /srv/www for web server data.
  16. /sys (System Information)

    • Virtual filesystem providing information about hardware devices and system settings.
    • Example:
      • /sys/class/net: Network interface details.
  17. /tmp (Temporary Files)

    • Temporary files created by users and applications.
    • Automatically cleaned up after a reboot.
  18. /usr (User System Resources)

    • Contains user-level programs, libraries, and documentation.
    • Subdirectories include:
      • /usr/bin: User binaries.
      • /usr/lib: Shared libraries.
      • /usr/share: Shared resources (e.g., man pages).
      • /usr/local: Locally installed software.
  19. /var (Variable Files)

    • Contains files that change frequently during system operation.
    • Examples:
      • /var/log: Log files.
      • /var/spool: Email and print jobs.
      • /var/tmp: Temporary files.

Summary Table

DirectoryPurpose
/Root directory, top of the hierarchy.
/binEssential command binaries.
/bootBoot loader and kernel files.
/devDevice files for hardware.
/etcSystem-wide configuration files.
/homeUser home directories.
/libEssential shared libraries.
/mediaMount points for removable media.
/mntTemporary mount points.
/optOptional third-party software.
/procVirtual filesystem for process info.
/rootHome directory for the root user.
/runRuntime process data.
/sbinSystem administration binaries.
/srvData for system services.
/sysVirtual filesystem for system info.
/tmpTemporary files.
/usrUser binaries, libraries, and docs.
/varVariable data like logs and spools.

Key Notes

  1. The Linux file system is modular, ensuring separation of concerns.
  2. Never modify critical directories (/bin, /lib, /sbin, /etc) unless absolutely necessary.
  3. Use /tmp for temporary data and /home for user files.

Understanding these directories helps in navigating, configuring, and administering Linux systems effectively.

Comments

Popular posts from this blog

Writing a Bash Shell Script

Bash shell scripts in Linux are text files that contain a series of commands that can be executed by the Bash shell. Bash (Bourne Again Shell) is a popular shell in Linux and UNIX systems, and shell scripts are used to automate tasks, configure systems, or perform a sequence of operations. How to Write a Bash Shell Script Create a New File: You can create a new script using any text editor like nano , vim , or gedit . gedit myscript.sh Write the Script: A basic shell script begins with a "shebang" ( #!/bin/bash ) to specify the interpreter that will be used to execute the script. The rest of the file contains the commands to be run. Example of a simple script: #!/bin/bash # This is a comment echo "Hello, World!" # Print "Hello, World!" #!/bin/bash : Specifies that the script will be executed using the Bash shell. echo "Hello, World!" : A command that prints the string "Hello, World!" to the terminal. Comments: Any line starting ...

Basic Linux Commands For Beginner's

Basic Linux Commands for Beginners Linux is an Operating System’s Kernel. You might have heard of UNIX. Well, Linux is a UNIX clone. But it was actually created by Linus Torvalds from Scratch. Linux is free and open-source, that means that you can simply change anything in Linux and redistribute it in your own name! There are several Linux Distributions, commonly called “distros”. A few of them are: Mint Ubuntu Linux Red Hat Enterprise Linux Debian Fedora Kali Linux is Mainly used in Servers. About 90% of the Internet is powered by Linux Servers. This is because Linux is fast, secure, and free! The main problem of using Windows Servers are their cost. This is solved by using Linux Servers. Forgot to mention, the OS that runs in about 80% of the Smartphones in the World, Android, is also made from the Linux Kernel. Yes, Linux is amazing! A simple example of its security is that most of the viruses in the world run on Windows, but not on Linux...

Linux History and GNU

Linus Torvalds ,a student at the University of Helsinki started developing Linux to create a system similar to MINIX, a UNIX operating system. In 1991 he released version 0.02; Version 1.0 of the Linux kernel, the core of the operating system, was released in 1994. About the same time, American software developer Richard Stallman and the FSF made efforts to create an open-source UNIX-like operating system called GNU. In contrast to Torvalds, Stallman and the FSF started by creating utilities for the operating system first. These utilities were then added to the Linux kernel to create a complete system called GNU/Linux, or, less precisely, just Linux. Linus Torvalds Richard Stallman Linux grew throughout the 1990s because of the efforts of hobbyist developers. Although Linux is not as user-friendly as the popular Microsoft Windows and Mac OS operating systems, it is an efficient and reliable system that rarely crashes. Combined with Apache, an open-source Web server, Linux accounts fo...