Directory Structure

The Linux directory structure is just like a tree. The first directory in the filesystem is aptly named the root directory "/" or you can say the base of the filesystem hierarchy begins at the root. The root directory has many folders and files in which you can store more folders and files, etc. Here is an example of what the directory tree looks like.

Linux Directory Structure
/The directory called “root.” It is the beginning point for the file system hierarchy.
/binBinaries and other executable programs.
/etcSystem configuration files.
/homeHome directories.
/optOptional or third party software.
/tmpTemporary space, typically cleared on reboot.
/usrUser related programs.
/varVariable data, most notably log files.


The /bin directory is where you will find binary or executable files. Programs are written in source code which is human readable text. Source code is then compiled into machine readable binaries. They are called binaries because machine code is a series of zeros and ones. The important thing to know is that commands, programs, and applications that you can use are sometimes located in /bin.

/bin contains the shells like bash and commonly used commands like cp,mv,rm,cat,ls,grep,tar,kill,echo,ps,gzip,ping,su and vi which used by both the system administrator and by non-privileged users. It contains essential binary files (unlike /usr/bin directory) also for booting. It may also contain commands which are used indirectly by scripts.

A list of all the programs in /bin can be viewed by using the ls command, which is commonly used to view the contents of directories, i.e.,

ls /bin

The following commands, or symbolic links to commands, are required in /bin.

catUtility to concatenate files to standard output
chgrpUtility to change file group ownership
chmodUtility to change file access permissions
chownUtility to change file owner and group
cpUtility to copy files and directories
dateUtility to print or set the system data and time
ddUtility to convert and copy a file
dfUtility to report filesystem disk space usage
dmesgUtility to print or control the kernel message buffer
echoUtility to display a line of text
falseUtility to do nothing, unsuccessfully
hostnameUtility to show or set the system's host name
killUtility to send signals to processes
lnUtility to make links between files
loginUtility to begin a session on the system
lsUtility to list directory contents
mkdirUtility to make directories
mknodUtility to make block or character special files
moreUtility to page through text
mountUtility to mount a filesystem
mvUtility to move/rename files
psUtility to report process status
pwdUtility to print name of current working directory
rmUtility to remove files or directories
rmdirUtility to remove empty directories
sedThe `sed' stream editor
shThe Bourne command shell
sttyUtility to change and print terminal line settings
suUtility to change user ID
syncUtility to flush filesystem buffers
trueUtility to do nothing, successfully
umountUtility to unmount file systems
unameUtility to print system information


Configuration files live in the /etc directory. Configuration files control how the operating system or applications behave. For example, there is a file in /etc that tells the operating system whether to boot into a text mode or a graphical mode.

The /etc hierarchy contains configuration files. A "configuration file" is a local file used to control the operation of a program; it must be static and cannot be an executable binary.

The following directories, or symbolic links to directories are required in /etc:

optConfiguration for /opt
X11Configuration for the X Window system (optional)
sgmlConfiguration for SGML (optional)
xmlConfiguration for XML (optional)

The following files, or symbolic links to files, must be in /etc if the corresponding subsystem is installed.

fstabStatic information about filesystems
host.confResolver configuration file
hostsStatic information about host names
hosts.allowHost access file for TCP wrappers
hosts.denyHost access file for TCP wrappers
networksStatic information about network names
passwdThe password file
resolv.confResolver configuration file
servicesPort names for network services
securettyTTY access control for root login


User home directories are located in /home. Linux systems can have multiple user accounts. Each home directory contains personal directories for the users. When we create a user on Linux system, it creates a home directory for the user.

Example, if Linux system has two users, Yogi and Dave. The home directory of their own at locations /home/yogi and /home/dave. Their home directory contains their personal data and user-specific configuration files. Home directories allow each user to separate their data from the other users on the system.


Traditionally, the /opt directory is used for installing third party applications that are not bundled with the operating system will often been installed in /opt. The normal practice is to keep the software code in opt and then link the binary file in the /bin directory so that all the users can run it.

Example, the Google Earth application is not part of the standard Linux operating system and gets installed in the /opt/google/earth directory.


Temporary directory is located in /tmp. As the name suggests, this directory holds temporary files. This directory is used by the operating system and many programs to store temporary files. Most Linux distributions delete the contents of /tmp at boot time/reboot, so do not store anything important over this directory.


These are shareable, read-only files, including executable binaries and libraries, man files, and other types of documentation. The /usr directory have the executable files, libraries, source of most of the system programs. For this reason, most of the files contained therein is read­-only (for the normal user).

  • "/usr/bin" contains basic user commands
  • "/usr/sbin" contains additional commands for the administrator
  • "/usr/lib" contains the system libraries
  • "/usr/share" contains documentation or common to all libraries

The /usr directory is called “user.” You will find user related binary programs and executables in the /usr/bin directory.