Linux Directory Structure

Let's learn about the Linux directory structure

References: howtogeek.comarrow-up-right, realforce111.tistory.comarrow-up-right, coding-factory.tistory.comarrow-up-right

Linux Directory Structure Diagram

  • Linux is a Unix-based OS, so it uses many parts of Unix as-is

    • In Unix, all system-related information and hardware devices are managed as files

      • Like Unix, Linux also manages system-related information as files!

  • Linux uses directories for efficient file management, organized in a Tree structure as shown above

  • Directories are categorized by the nature, content, and access permissions of commands

  • Most Linux distributions

    • Use FHS (Filesystem Hierarchy Standard), and

    • Store files with the same purpose in the same location, so

      • System resources and programs can be easily found

        • In other words, commands / files / documents are managed in their own separate locations!

Directory Structure

I am currently using Ubuntu 18.04, one of the Linux distros, and the directory structure is as follows

/ - The Root Directory

  • The top-level directory

  • Must exist when setting up partitions!

  • The directory that serves as the reference for absolute paths

/bin - Essential User Binaries

  • The directory containing Linux basic commands (binaries)

  • Contains the essential commands needed for system operation

  • Contains commands required for booting

    • Also contains general commands that system users can use after booting

/boot - Static Boot Files

  • The directory containing kernel images and boot information files needed for system booting

  • Contains the kernel boot image file specified in /etc/lilo.conf

  • A very important directory during booting!

/cdrom - Historical Mount Point for CD-ROMs

  • Not included in the FHS standard, but can be found in distros including Ubuntu

  • A temporary storage location for CD-ROMs

/dev - Device Files

  • The directory where device files are stored

  • However, they are not actual files!

    • It is a virtual file system that does not take up physical space

/etc - Configuration Files

  • The directory containing system configuration files

    • Network-related configuration files

    • User information / password information

    • File system information

    • Security files

    • System initialization files and other important configuration files are located in this directory

/home - Home Folders

  • The location where system user home directories are created

  • When a user account is created, a new user directory with the same name as the account is created as a subdirectory under /home!

  • Since my Ubuntu only has one user chloe, the /home directory looks like this!

/lib - Essential Shared Libraries

  • The directory containing Library files that the binaries in /bin and /sbin folders depend on

    • Libraries that the binaries in /usr/bin depend on are located in /usr/lib!

  • Kernel module files exist in /lib/modules

  • Most libraries are connected via links

/media - Removable Media

  • The directory for connecting external devices such as CD-ROMs and USB drives

/mnt - Temporary Mount Points

  • The directory for temporarily mounting file systems

  • Generally used when mounting other devices

    • Other directories can also be used!

/opt - Optional Packages

  • The directory where additional packages are installed

/proc - Kernel & Process Files

  • Stores various processor, program information, and hardware information of the system

  • Like the /dev directory, it is a virtual file system that does not have physical capacity!

    • It is not stored on the hard disk, but stored in memory by the kernel

  • Shows the current system configuration

  • You can check system information by using the cat command on files inside the /proc directory

    • ex) Checking Interrupt information - cat /proc/interrupts

/root - Root Home Directory

  • The home directory of the root user

    • Both / directory and /root are called root, but they are different!

/run - Application State Files

  • The directory where files related to running services are stored

/sbin - System Administration Binaries

  • Similar to the /bin directory, but contains executable commands related to system administration

    • System check and recovery commands

    • System initialization and shutdown commands, and other executable files needed for system administration exist here!

/srv - Service Data

  • The directory where data for services provided by the system such as FTP and Web are stored

/tmp - Temporary Files

  • Stores temporary data generated during system use

    • Gets cleared during booting!

/usr - User Binaries & Read-Only Data

  • Contains most program library files for general users

    • Basic executable files

    • Library files

    • Header files and other files are stored in this directory

/var - Variable Data Files

  • The directory where data and logs (operation records) generated during system operation are stored

  • Stores dynamic files used by the system

    • Variable data storage directory

Last updated