> For the complete documentation index, see [llms.txt](https://hacking101.ethicalhackx.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking101.ethicalhackx.com/readme/linux-101/linux-file-system.md).

# Linux File System

### Linux File Systems

Linux supports many file systems ( EXT3, EXT4, XFS . . . ), the main purpose of the File Systems is providing methodology to Store files and folders in organised manner. File System decides many times they method files are stored, name\_length and path\_length limits, file\_size limits among many other criteria. Many File Systems are specialised for specific purpose like Logging, long term archive, speed (performance) and more, where as some FileSystems are for General purpose use.

### Linux Directory Structure

*Linux Directory structure across various Linux distributions is similar, only slight variations which will be mentioned. Knowing about Linux File System and Directory structure is crucial because the target system has high chances of being a Linux machine and it helps if we know what directory holds some useful juicy information for us.*

| Directory           | Description                                                                                                                                                                                                            |
| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| / (root filesystem) | root filesystem is the top-level directory of the filesystem. A symbolic link to most of the directories below are present in /(root) .                                                                                |
| /bin                | bin contains user executable files.                                                                                                                                                                                    |
| /boot               | Static files of the boot loader                                                                                                                                                                                        |
| /dev                | dev contains the device files for every hardware device attached to the system. These are not device drivers, rather they are files that represent each device on the computer and facilitate access to those devices. |
| /etc                | Host-specific system configuration                                                                                                                                                                                     |
| /home               | Home directory storage for user files. Each user has a subdirectory in /home. (except root user)                                                                                                                       |
| /lib                | Shared library files that are required to boot the system.                                                                                                                                                             |
| /media              | A place to mount external removable media devices such as USB thumb drives that may be connected to the host.                                                                                                          |
| /mnt                | A temporary mount-point for regular filesystems (as in not removable media) that can be used while the administrator is repairing or working on a filesystem.                                                          |
| /opt                | Additional programs and packages are located here.                                                                                                                                                                     |
| /root               | home directory for the root user.                                                                                                                                                                                      |
| /sbin               | System binary files, executables used for system administration.                                                                                                                                                       |
| /tmp                | Temporary directory is used by many programs and OS to store temporary files. Temporary files can be removed any time.                                                                                                 |
| /usr                | These are shareable, read-only files, including executable binaries and libraries, man files, and other types of documentation.                                                                                        |
| /var                | Variable data files are stored here. This can include things like log files, MySQL, and other database files, web server data files, email inboxes, and much more.                                                     |

### Use of Directories

This can be a personal preference how we setup Linux , and can be as per organisational or application needs too. While setup of Linux Distributions we are offered to place all files in / (root) , that is single partition. Configurations can be :

* 1-Single root partition holding everything under /(root) - most common one.
* /(root) + EFI (System Partition) ( usually upto 500MB in SIze) - for EFI setups, where EFI partition is FAT32 formatted. I will not be mentioning EFI separately and consider is choosen accordingly.
* /(root) + /home - where base installation and user files - /home is placed on different partitions as per need, in case setup goes wrong, /home files are still safe on different partition.
* /(root) + /home + /var - when logging is the requirement or possibly the web-server files present in /var needs ample of space and rest is separated.
* /opt can be given a separate partition if too many additional programs and packages are to be configured.
* This is just informational and can be adjusted according to the needs.

#### References

#### <https://www.pathname.com/fhs/>

#### Linux Directory Structure - <https://youtu.be/kSr9R8K66S8>

\
**Linux Directory Structure** - <https://youtu.be/42iQKuQodW4>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hacking101.ethicalhackx.com/readme/linux-101/linux-file-system.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
