Purpose of Linux File System Structure

The arrangement of files in a Linux system may seem at first to be a semi-arbitrary arrangement of files
and directories, based on historic practice. To an extent that’s true, but over the years the layout has evolved for good reasons into the hierarchy we see today. The general idea is to separate files and directories into three groups:

  • Files and directories that are unique to a particular system running Linux, such as start-up
    scripts and configuration files.
  • Files and directories that are read-only and may be shared between systems running Linux,
    such as application executables.
  • Directories that are read/write, but may be shared between systems running Linux or other
    operating systems, such as user home directories.

Here we look briefly at the purposes of each of the standard subdirectories of the / (root) directory:

  • /bin — This contains binary files that can be used both by the root user and ordinary users, but are essential to operation in single-user mode, when some other directory structures may not be mounted. For example, core commands such as cat and ls would normally be found in here, as will sh.
  • /boot — This directory is used for files required during booting of the Linux system. It is frequently quite small, less than 100 MB, and often a separate partition. This is handy on PC-based systems, where there are frequently BIOS limitations on the active partition, requiring it to be in the first 2 G or 4 G of the disk. Having this as a separate partition allows more flexibility when deciding how to lay out the rest of the disk partitions.
  • /dev—This contains the special device files that map to hardware. For example, /dev/hda will be mapped to the first IDE disk.
  • /etc — This contains configuration files. Historically some binaries could also be found in here, but that is no longer true on most Linux systems. The best known file in the /etc directory is probably passwd, which contains information on users. Other useful files are fstab, listing mount options; hosts, listing IP to host name mappings, and the httpd directory, which contains
    configuration for the Apache server.
  • /home—This is a directory for user files. Normally each user will have a single directory under this directory with the same name as their login, and this will be their default login directory. For example, after logging in, the user rick will almost certainly find himself in the /home/rick directory.
  • /lib — This contains essential shared libraries and kernel modules, specifically those that will be required while the system is booting or in single-user mode.
  • /media — This is intended as a top-level directory to contain other directory mount points for removable media. The intention is to remove unnecessary top-level directories, such as /cdrom and /floppy.
  • /mnt — This is simply a convenient place for mounting additional file systems temporarily. Historically some distributions have added subdirectories for the different devices, such as
  • /cdrom and /floppy under /mnt, but the preferred location for these is now under /media, returning /mnt to its original purpose, as a single top-level temporary mount location.
  • /opt — This is a directory for software vendors to use when adding additional software applications to the base distribution. Distributions should not use it for software they distribute as part of the standard distribution, but leave it free for third-party vendors to use. Generally, vendors will create a subdirectory with their name, and then further subdirectories such as /bin and /lib for files specific to their application.
  • /root — This is for files used by the root user. It is not in the /home directory part of the tree, because that may not be mounted in single-user mode.
  • /sbin — This is used for commands normally used only by the system administrator, and required while the system is booting or in single-user mode. Commands such as fsck, halt, and swapon live here.
  • /srv — This is intended as a location for site-specific read-only configuration data, however it is currently not in common use.
  • /tmp — This is used for temporary files. It is usually, but not always, cleared when the system is booted.
  • /usr—This is a rather complex secondary file system, generally containing all the system-type commands and libraries not required during system booting or in single-user mode. It has many subdirectories, such as /bin, /lib, /X11R6, and /local.
  • /var — This contains data that changes frequently, such as spool files for printing, application log files, and mail-spooling directories.
You may also like:

Sarcastic Writer

Step by step hacking tutorials about wireless cracking, kali linux, metasploit, ethical hacking, seo tips and tricks, malware analysis and scanning.

Related Posts