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.
|/||The directory called “root.” It is the beginning point for the file system hierarchy.|
|/bin||Binaries and other executable programs.|
|/etc||System configuration files.|
|/opt||Optional or third party software.|
|/tmp||Temporary space, typically cleared on reboot.|
|/usr||User related programs.|
|/var||Variable data, most notably log files.|
/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 contains the shells like bash and commonly used commands like
which used by both the system administrator and by non-privileged users. It contains essential binary files (unlike
ls,grep,tar,kill,echo,ps,gzip,ping,su and vi
/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.,
The following commands, or symbolic links to commands, are required in /bin.
|cat||Utility to concatenate files to standard output|
|chgrp||Utility to change file group ownership|
|chmod||Utility to change file access permissions|
|chown||Utility to change file owner and group|
|cp||Utility to copy files and directories|
|date||Utility to print or set the system data and time|
|dd||Utility to convert and copy a file|
|df||Utility to report filesystem disk space usage|
|dmesg||Utility to print or control the kernel message buffer|
|echo||Utility to display a line of text|
|false||Utility to do nothing, unsuccessfully|
|hostname||Utility to show or set the system's host name|
|kill||Utility to send signals to processes|
|ln||Utility to make links between files|
|login||Utility to begin a session on the system|
|ls||Utility to list directory contents|
|mkdir||Utility to make directories|
|mknod||Utility to make block or character special files|
|more||Utility to page through text|
|mount||Utility to mount a filesystem|
|mv||Utility to move/rename files|
|ps||Utility to report process status|
|pwd||Utility to print name of current working directory|
|rm||Utility to remove files or directories|
|rmdir||Utility to remove empty directories|
|sed||The `sed' stream editor|
|sh||The Bourne command shell|
|stty||Utility to change and print terminal line settings|
|su||Utility to change user ID|
|sync||Utility to flush filesystem buffers|
|true||Utility to do nothing, successfully|
|umount||Utility to unmount file systems|
|uname||Utility 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:
|opt||Configuration for /opt|
|X11||Configuration for the X Window system (optional)|
|sgml||Configuration for SGML (optional)|
|xml||Configuration for XML (optional)|
The following files, or symbolic links to files, must be in /etc if the corresponding subsystem is installed.
|fstab||Static information about filesystems|
|host.conf||Resolver configuration file|
|hosts||Static information about host names|
|hosts.allow||Host access file for TCP wrappers|
|hosts.deny||Host access file for TCP wrappers|
|networks||Static information about network names|
|passwd||The password file|
|resolv.conf||Resolver configuration file|
|services||Port names for network services|
|securetty||TTY 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/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.
/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
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
/usr directory is called “user.” You will find user related binary programs and executables in the