The Linux file system hierarchy is much different than that of Windows. So much so that it becomes a show stopper for many new users. I hope to clear up a lot of the confusion here and now at gHacks. So, without further adieu, I give you the Linux file system hierarchy.
/ - This is the base, or root, of the file system. Everything in the Linux system is housed in this directory.
/bin - This directory contains a number of essential commands that are available to unprivileged users (such as cat, chmod, chown, etc). The /bin directory also houses the shells (such as bash).
/boot - This directory contains everything necessary for the boot process. Without the /boot directory, your machine would not be able to boot up.
/dev - This directory contains all of the special and device files. With Linux all devices and drives have a name. Hard drives tend be labeled as hda, hdb, hdc. Special devices such as external usb devices can be labeled as sda, sdb, sdc. If you look in the /dev directory you will see quite a few files that can be associated with devices. Most of the devices found here are either block or character devices. Block devices hold data (such as a hard drive) and character devices transmit data (such as a mouse).
/etc - This is a very special directory that contains numerous configuration files and directories. This directory will contain the X configurations, Apache, Samba, the init system, etc. The /etc directory also houses the sources for package management systems like apt and yum. One of the most important subdirectoris in /etc is the /etc/init.d (or in Red Hat based systems, /etc/rc.d/init.d). This subdirectory contains all of the initialization scripts for services such as networking, samba, apache, cron, hal, etc.
/home - This is where all user data is housed. Each user on the system will have their own subdirectory within /home. All user data and user-specific configuration files are saved here.
/lib - This is where all kernel modules needed for system boot libraries that are required by root system commands (commands found in /bin and /sbin.)
/lost+found - If your system crashes or is shut down improperly any lost data will be stored here. During a recovery boot the fsck application will attempt to recover corrupt files found here.
/media - This is where all external media (or extra internal drives) is mounted. If you make or edit entries in the /etc/fstab file you will point devices (such as /dev/sda to directories withing /media.)
/mnt - This is another directory where external (and internal) drives and devices are mounted. This is a holdover to older school thought. Most modern distributions are moving to the /media directory.
/opt - This is a directory that can be used for installing applications that are outside of the default installation. When you install applications here they can be used system wide by all users. Only the root user can install applications here.
/proc - This is a special directory that is actually a virtual filesystem. The /proc directory acts as a process information center for the kernel.
/root - This is the root users home directory.
/sbin - This is where all system maintenance/administration executable files are stored. These commands differ from those in /usr/sbin in that they are system commands used for critical system administration and maintenance whereas /usr/sbin are non-critical tasks such as user administration, network administration, etc.
/usr - This is one of the largest directories on your system as it contains all user-executable binaries as well as the libraries, documentation, and header files for these executables. One of the most important subdirectories is /usr/bin where all user application executables are stored.
/var - This directory contains all variable data such as log files. On a server environment the document root directory of most servers will be found here (/var/www and /var/ftp are examples.)
/srv - This directory can contain the services (such as www) directory in some distributions.
/tmp - This directory, as you would expect, contains temporary files that are stored as needed. Many files you will find here are lock files created by applications. Do not remove anything from this directory as the cron system has a job specifically created for the removal of these files.
And there you have it. A description of each directory in the Linux file system hierarchy.
Advertising revenue is falling fast across the Internet, and independently-run sites like Ghacks are hit hardest by it. The advertising model in its current form is coming to an end, and we have to find other ways to continue operating this site.
We are committed to keeping our content free and independent, which means no paywalls, no sponsored posts, no annoying ad formats (video ads) or subscription fees.
If you like our content, and would like to help, please consider making a contribution:
Ghacks is a technology news blog that was founded in 2005 by Martin Brinkmann. It has since then become one of the most popular tech news sites on the Internet with five authors and regular contributions from freelance writers.