Linux Directory Structure

The Linux Filesystem Hierarchy

/
/bin
/boot
/dev
/etc
/home
/lib
/mnt
/lost+found
/opt
/proc
/root
/sbin
/tmp
/usr
/var
References

Introduction

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
/

Subdirectories
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:

$ls /
You will see a list of subdirectories outputed to the screen. All these directories are explained below.

/bin
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:

Shell programs

* bash
* sh

File manipulation programs

* tar
* echo
* vi
* grep

Process handling programs

* kill
* ps

/boot
Stored in this directory are files that are required for the Linux boot process. Such files include vmlinuz, the Linux kernel file.

/dev
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).

/etc

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).

/home
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.

/lib
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/

/mnt
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.

/lost+found
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).

/opt
Used for storing random data that has no other logical destination.

/proc
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.

/root
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.

/sbin
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.

/tmp
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.

/usr
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.

/var
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.

References

Valid XHTML :: Valid CSS: :: Powered by WikkaWiki