Useful general guide to what folders hold what in the Linux hierarchy, reproduced from computer bank.
The Linux Filesystem Hierarchy
In the Linux operating system, all filesystems are contained within one directory hierarchy. The root directory is the top level directory, and all its subdirectories make up the directory hierarchy. This differs to other operating systems such as MS-Windows which applies a separate hierarchy for each device and partition.
The Linux directory hierarchy at a glance
The following directories are contained within the structure:
Top level directory
bin sbin lib usr var boot dev etc home mnt proc root tmp lost+found opt
The Linux Filesystem Hierarchy
Listed below are the directories contained within the root filesystem.
The Linux filesystem has the root directory at the top of the directory tree. The following list of directories are subdirectories of the root directory. This directory is denoted by the / (pronounced “slash”) symbol. To view the list of directories from the root directory, enter the following in the command line:
Contains executable programs such as ls and cp. These programs are designed to make the system usable. Programs within /bin are required for system repairing. Some of the files located in the /bin directory include:
File manipulation programs
Process handling programs
Stored in this directory are files that are required for the Linux boot process. Such files include vmlinuz, the Linux kernel file.
Contains device files required for interfacing with hardware. Devices in UNIX are either block or character devices. Examples of character devices are your keyboard, mouse and serial port. Block devices can include the floppy drive, CD-ROM drive and hard disk. Common files in /dev include:
* psaux (interface to PS/2 mouse)
* modem (interface to modem hardware)
* ttyS0 (first serial port)
* tty0 (first virtual console).
Contains configuration files which are local to the machine. Programs store configuration files in this directory and these files are referenced when programs are run. Common files or directories found in /etc include:
* /etc/X11/ (the X Window configuration directory)
* profile (system-wide environment configuration file).
Contains user account directories. Each user created by the system administrator will have a subdirectory under /home with the name of the account. This is the default behaviour of Linux systems. E.g. User account for Anna is created, her home directory will be located in /home/anna. All her personal files will reside in this directory. All participants in this class are using the home directories of their respective user accounts. At Computerbank, /home is served via the network, enabling users to access their home directory from any networked machine.
Contains shared object library files that are necessary to boot the system as well as containing files required by various programs such as rm and ls. This directory also contains modules (located in /lib/modules) which can be loaded into the kernel. Files of interest in /lib include:
* libm.so (shared object file used for math functions)
* libc.so (C programming library used for all system and library calls).
Module files are located in /lib/modules/`uname -r`/kernel/
Used for mounting temporary filesystems. When mounting a CD-ROM for instance, the standard mount point location is /mnt/cdrom. On the Debian GNU/Linux systems at Computerbank, the mount point has been changed to /cdrom.
When the filesystem cannot properly identify files, the respective files are placed in this directory. If data appears to have been lost mysteriously, it is a good idea to check in this direetory (or ask your system administrator to check for you).
Used for storing random data that has no other logical destination.
Provides information about running processes and the kernel. A directory is provided for each running process. Useful system information such as the amount of Random Access Memory (RAM) available on the system as well as Central Processing Unit (CPU) speed in Megahertz (MHz) can be found within the /proc directory. The following commands will give you this information:
$ cat /proc/cpuinfo – Display CPU information of system
$ cat /proc/meminfo – Display RAM information as well as swap space capacity and usage.
This is the home directory for the super user (root). This directory is not viewable from user accounts. The /root directory usually contains system administration files.
Similar to /bin, this directory contains executable programs needed to boot the system, however the programs within /sbin are executed by the root user. Contains system maintenance programs, examples of which are:
* ifconfig (interface configuration, use this command to add or remove a network interface)
* mkfs (make a filesystem on a partition)
* lilo (boot loader software, tells your Master Boot Record (MBR) where to find your operating system(s). Linux Loader (LILO) stores its working files in /boot.
This directory is used for temporary storage space. Files within this directory are often cleaned out either at boot time or by a regular job process. The Debian GNU/Linux operating system cleans up the /tmp directory at boot time. An example for using the /tmp directory in Computerbank would be when downloading the OpenOffice deb packages. By downloading these packages into the /tmp directory, the user can be assured the packages will be wiped off the system next time the machine reboots.
Used to store applications. When installing an application on a Debian GNU/Linux machine, the typical path to install would be /usr/local. You will notice the directory structure within /usr appears similar to the root directory structure. Some directories located within /usr include:
* /usr/doc – Documentation relating to the installed software programs.
* /usr/bin – Executable programs that are not required for booting or repairing the system.
* /usr/local/src – Source code for locally installed applications.
This directory contains files of variable file storage. Files in /var are dynamic and are constantly being written to or changed. Some directories located within /var include:
* /var/spool – files in the print queue
* /var/log – files containing logging information
* /var/run – files containing the process ID’s for each current process.