Directory Structure in Linux

A computer system organizes all of its files in what is called a directory structure. The directory structure itself resides on what is called a partition – a low-level structure in which files and directories reside. Each directory contains information such as the name, location and size of each file.

The Linux directory structure is a tree structure and is composed of:

  • / is the root directory where the directory structure begins. Every file and directory in the system is under the root directory.
  • /boot is where Linux keeps files and information needed for booting up. It contains vmlinuz which is the kernel.
  • /etc contains the configuration files for the system.
    • /etc/inittab is a file that describes the processes are started on boot
    • /etc/fstab contains descriptive information about floppies, CD-roms and so on.
    • /etc/passwd contains the user definitions
  • /bin, /usr/bin contain the most important programs (binaries) that the system needs to operate, such as the shells, ls, and grep.
  • /sbin, /usr/sbin contains system admin programs which can only be run by the root user.
  • /usr is the directory that stores user applications and is usually the largest directory.
    • /usr/doc contains documentation for user apps.
    • /usr/share contains configuration files for user apps.
    • /usr/src contains source files for user apps.
    • /usr/include contains header files for the C compiler.
    • /usr/local is where apps and files are housed that are strictly on the local machine. If the machine is on a network, the /usr directory may be physically in another location, so /usr/local contains only the information that should be on the local machine and not shared by other access points in the network.
  • /lib houses the shared libraries for programs that are dynamically linked (compared to DLL’s on Windows)
  • /home is where the users keep their personal files.
  • /root is the super user’s home directory.
  • /var contains variable data that is constantly changing while the system is running.
    • /var/log contains log files like error reports.
    • /var/mail – incoming/outgoing mail is stored here.
    • /var/spool – holds files that are queued for some process, like printing.
  • /tmp contains temporary files written by programs.
  • /dev holds the devices that are available to the system, like floppy disks and cd-roms.
  • /mnt is a directory used for mount points. The different physical storage devices must be attached to some directory in the tree structure before they can be accessed.
  • /proc is a virtual directory that contains information about the kernel.
  • /lost+found is where Linux keeps files after a system crash.
Linux Directory Structure
The linux hierarchy of directories.

Leave a Reply

Your email address will not be published. Required fields are marked *