# The Linux File-System

This is not exactly a tutorial but a guide to better understand how the **Linux File-System** or Filesystem Hierarchy Standard (FHS) is used and the purpose of the various directories in the file-system hierarchy. I have spent years seeing people create new directories in their home directory to replace what the file-system already provides.

Think of the Linux file-system as an inverted tree. At the top is the root, mostly referred to as a single slash **`/`**. Not to be confused with the root user whose home directory is typically under the slash `/` then **`/root`**. When you become the root user by typing in `sudo -i` and change to the home directory with `cd` on the terminal line, this is where you are taken.

The **`/`** character is also used as a directory separator in filenames. You may notice that in Windows the separator is the other way `\`. 
Subdirectories are any directory under the root directory. These are used for a standardized purpose to organize the files by type and purpose. This makes it easy to find libraries and configuration files that are needed to be accessed.
For example, the `/boot` subdirectory is used to store files needed to boot the system.

## In most Linux file-systems
In Most Linux file-systems you have several subdirectories that serve a specific purpose. Some house configuration files. Some are meant specifically for variable data. 
Some house your personal data. Knowing where to find what will reward you when starting down your Linux journey.


- **/bin** Essential command binaries that need to be available in single-user mode; for all users, e.g.,

- **/usr** The `/usr` (user) subdirectory houses installed software, shared libraries, it includes files and some program data. It also in itself has subdirectories:
    - `/usr/bin` For user commands such as `systemctl`
    - `/usr/sbin` For system administration commands.
    - `/usr/local` For your customized software.

- **/etc** The name is short for **et cetera**. It houses configuration files specific tot he system. For example, to mount a partition at boot you need to edit the `fstab` file found in `/etc`. When you install a web server on your Linux machine the configuration file, or files will be found under `/etc` also files like `hostname`.

- **/var** Variable data that should remain intact between boots. Files that dynamically change like databases, cache directories, log files, and website content may be found under the /var directory.

- **/run** Every time your computer boots it creates locked and runtime files. These are kept in this directory among other things. When your computer restarts these files get recreated.

- **/home** The home directory is where personal data is stored. Documents, Pictures, Videos.

- **/root** Home directory for the administrative superuser.

- **/tmp** The temp directory is widely underused. It is a world writeable directory reserved for temporary files. Files that have not been changed or accessed for 10 days are deleted from this directory automatically. A lot of people download their zip files here prior to extracting to another directory.

- **/boot** This resides the files needed in order to start the boot process.

- **/dev** The dev directory stands for _device files_ that are used by the system to access hardware. Objects such as USB, hard drives, block devices are organized here.

Some distributions generally follow the standard but deviate from it in some areas.
Once you understand the filesystem and where to go in order to set up complicated configurations that are involved with Linux then the easier they become. Users new to Linux can find it daunting and easily give up after their first try at installing packages or setting up printers. I hope to ease you through the transition of Windoze to Linux and show you the world of opensource.

Check out the podcast ** [Command Line Heroes](https://www.redhat.com/en/command-line-heroes) ** brought to you by Red Hat and my friend _Saron Yitbarek_ now in their 5th season. She tells stories of the remarkable history of how this community and the technology that built it came to be.
