Linux File Hierarchy Structure

Linux File Structure

Why to learn about file structure.

  • Developers benefit from understanding where libraries, executables, and other resources should be placed.
  • For instance, knowing that libraries are typically in /lib or /usr/lib helps in setting correct paths during development and deployment.

Types of Directories in LFHS

Types of Directories in LFHS

Indepth Explation about each directory

1. / (Root):

  • Every single file and directory start from the root directory.
  • The only root user has the right to write under this directory.
  • /root is the root user’s home directory, which is not the same as /

2. /bin:

  • The /bin folder in Linux is like a toolbox full of essential tools that everyone on the system can use.
  • Inside this folder, you'll find important commands like 'ls' for listing files, 'cp' for copying files, and 'cat' for displaying file contents.
  • These commands are used by both regular users and the system itself.

3. /boot:

  • The /boot folder is like the starting point of your computer's operating system.
  • It contains important files that help your computer start up, including the Linux kernel and bootloader.
  • These files are necessary for your computer to load the operating system and get everything running smoothly.

4. /dev:

  • The /dev folder is like a special library that helps your computer talk to all the hardware devices connected to it.
  • Inside this folder, you'll find files that represent things like hard drives, USB drives, and printers.
  • These files allow the operating system to communicate with the hardware and make it work properly.

5. /etc:

  • The /etc folder is like the control center of your Linux system.
  • It contains important configuration files that tell the system how to behave and work.
  • For example, it has files that manage user accounts, network settings, and system services.
  • These files are crucial for the system's operation and can be edited by system administrators.
  • However, it's important to be careful when making changes here, as it can affect the entire system.

6. /home:

  • The /home folder is like a personal space for each user on the system.
  • Inside this folder, you'll find individual directories for each user, where they can store their files and settings.

7. /lib:

  • The /lib folder is like a toolbox that contains essential tools and libraries needed for the system to run smoothly.
  • These libraries are used by various programs and commands to perform their tasks.
  • For example, if a program needs to do some math calculations, it might use a library from this folder to help it out.

8. /media:

  • The /media folder is like a parking lot for removable storage devices, such as USB drives and CDs.
  • It's like a temporary storage area for these items while you're using them.
  • For instance, if you insert a CD, your computer might put it in a folder called '/media/cdrom', and if you plug in a USB drive, it might create a folder called '/media/usb' to access it.

9. /mnt:

  • The /mnt folder is like a special place where you can temporarily attach or mount other file systems or devices.
  • For example, if you have an external hard drive or a network share, you can use this folder to access its contents without moving it around.
  • It's a convenient way to work with different storage locations on your system.

10. /opt:

  • The /opt folder is like a special storage area for optional software packages that are not part of the standard system installation.
  • When you install additional software, it often goes into this folder to keep things organized.
  • For example, if you install a new application, it might create a directory in /opt to store its files and settings.

11. /proc:

  • The /proc folder is like a window into the inner workings of your Linux system.
  • It contains virtual files that provide real-time information about the system's processes, memory usage, and hardware.
  • For example, if you want to see how much memory is being used, you can check a file in /proc called 'meminfo'.

12. /srv:

  • The /srv folder is like a storage area for data that is served by the system's services.
  • For example, if you have a web server running, the files that are served to users might be stored in a directory under /srv.
  • It's a way to keep service-related data organized and separate from other files on the system.

13. /sys:

  • The /sys folder is like a special interface that provides information about the system's hardware and devices.
  • It contains virtual files that allow you to interact with and configure hardware components.
  • For example, you can check the status of devices or change their settings through files in /sys.

14. /tmp:

  • The /tmp folder is like a temporary storage area for files that are needed only for a short time.
  • Programs often use this folder to store temporary files while they are running.
  • For example, if you're downloading a file, it might be temporarily stored in /tmp before being moved to its final location.

15. /usr:

  • The /usr folder is like a big storage area for user-related programs and files.
  • It contains subdirectories for applications, libraries, and documentation that are used by regular users.
  • For example, you'll find the 'usr/bin' directory with many common commands and programs that users can run.