Home » Linux Basics » 05 - Notes on Installation and Configuration
5

Linux - Typical Directory Structure

Organizing in accordance to the functions of the files and programs within the directory

The directories of the Linux OS are organized according to the functions of the files and programs within the directory. At the top of the hierarchy is the root directory. The main directories under the root directory have a specially laid out structure and function:

Screenshot 5e: Root Directory Contents
Screenshot 5e: Root Directory Contents

Description System.map
Directory/file System.map
Various binary applications/executable files /bin
Files the system uses when booting including the kernel image /boot
Common location for shared data (not part of default installation) /data
Device nodes and files /dev
Programs and files typically used for system configuration /etc
Common location for home directories /home
Shared libraries required by operating system /lib
Used to store restored files after a filesystem check /lost+found
Mount point for various media /mnt
Optional software /opt
Common location for Oracle database files /oracle
Pseudo-Filesystem with information about executing processes /proc
Typical location of the home directory for the root user (a symbolic link) /root
System binaries (executables) /sbin
Temporary storage /tmp
Contains user related sub-directories /usr
Files that change (vary) as the system runs, such as log and status files /var
Linux kernel image vmlinuz
  • The vmlinuz contains main kernel functions. While executing, the vmlinuz file is the kernel itself.
  • As indicated by the /bin directory's name, it is used to store system-related binaries and executables. Many programs here cannot be executed by regular users but everyone has read access. The executables of several utilities may be part of this directory. The /sbin directory is also used to store administration related applications and executables.
  • The /boot directory is used while starting up the system. It contains associated snapshots (i.e. system state at a certain point of time) and certain log files.
  • The /dev directory contains device nodes. Each device is accessed only the the respective file in this directory. /dev/null is a sort of 'black hole'; any output or other information sent here just disappears
  • The /etc directory contains configuration related files and programs. Some important sub directories of the /etc directory include etc/cron type directories that contain cron job related information. Cron jobs are OS scheduled tasks that take place at regular intervals. The /etc/init or /etc/rc directory contains certain startup and shut down related scripts. The skeleton configuration files that are all copied into a new user's directory are usually stored in /etc/skel. A Default system configuration used to recover from crashes, the shell configuration, and security configuration are all located in a sub directory of /etc.
Screenshot 5f: etc Directory Contents
Screenshot 5f: etc Directory Contents
  • The /home directory is the default location for each user's home directory. Normally, this directory contains a subdirectory for each system user and the name of the subdirectory corresponds to the user's userid.
  • A /lost+found directory is sometimes used to store files that are no longer associated with a directory. Files recovered after system crash and restore and so on are placed here.
  • The /lib directory contains the utilities and libraries the OS requires
  • The /proc directory is used to indirectly get information about currently executing processes and files loaded into memory.
  • The 'root' user or superuser is the administrator of the OS. Normally, a group of persons have 'root' access and associated permissions. The /root directory is the home directory of the 'root' user. This is just a symbolic link to '/' on most systems.
  • User related sub-directories are stored under the /usr directory. Of these, usr/adm contains data, logs, and system messages, /usr/include contains files that programs use at compilation time. The /usr/src directory contains the source code of the kernel and all installed packages.
Screenshot 5g: usr Directory Contents
Screenshot 5g: usr Directory Contents
  • The UNIX command for general help is 'man'. The /usr/man directory typically contains the indexed manual pages (help files). Files waiting to be sent to peripheral devices like printers and modem are temporarily stored in the /usr/spool directory.
  • X-Windows provides a Graphical User Interface and rich multimedia functionality to Linux and UNIX systems. The /usr/X11 directory contains X Windows System files.
  • A significant amount of information is dynamic – it logs  and files record commands and errors as they happen. Lock files represent currently used devices and files that are locked for modification, outgoing mail spools keep changing as the mails they contain are sent on their way. Files and other information that keep changing are stored in subdirectories of /var.

You may not understand the significance of each of these directories right now; that is OK. This chapter should familiarize you with a typical Linux filesystem. You will get to know more about key directories and contents over the rest of the tutorial.