# Navigating the Linux File System (LFS)

Imagine Linux's File System (LFS) as the backbone of where all your computer's data is stored. Drawing inspiration from UNIX, one cool thing about Linux is that it treats almost everything – be it data, commands, shortcuts, or whatever –  as items in the filesystems. Knowing where things are, and understanding how to get around the filesystem from the shell, are critical skills in Linux!

Now, all this data lives inside what we call **directories**, or "folders" as you probably know them if you are predominantly a Windows user. And these directories? They can house both files and other  nested directories. Think of it as a family tree. To find a file or a directory, you can be all formal and use the full address, like `/home/chris/myfile.txt`. Or, if you're already in `/home/chris`, just saying `myfile.txt` gets the job done.

Picture the Linux file layout as an upside-down tree. At the very top, we've got the daddy of all directories, the **root,** depicted as a simple slash `/`. And nope, it's **NOT** the same as the root user... Dive deeper, and you've got its children: common directories like `bin`, `dev`, `home`, and a few others. Each of these can have their own little set of subdirectories. So, if you ever sketch this out, you'd see a sprawling family tree, or hierarchy, starting with the root directory at the top:

<figure><img src="/files/RhEZsADmRh5xnyXjUEoL" alt=""><figcaption><p>A visual depiction of the LFS</p></figcaption></figure>

Let's focus on one of the directories found just below the LFS root: the `/home` directory.

Inside, there's a specific space for my user, named chris. **The directory typically shares the same name as the user account**. My space is well-organised. I have areas designated for Desktop items, Documents, Downloads, and several other folders.

Now, inside my Documents directory, there's a subdirectory named `memos`, and within that, a file named `memo1.doc`:

* If I want to reference this file from **anywhere** in the system, I'd say it's located at `/home/chris/Documents/memos/memo1.doc` - this is known as the **absolute path** as it is true no matter where within the file system I am currently working
* However, if I were already navigating within `/home/chris/`, I could shorten my reference to `Documents/memos/memo1.doc` - this is known as a **relative path** because it is only true when considered in relation to my current working directory

There are several directories within Linux that are of interest, and it's worth getting familiar with them:

| Directory | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `/bin`    | Contains common Linux user commands, such as `ls`, `sort`, `date`, and `chmod`. `/boot` Has the bootable Linux kernel, initial RAM disk, and boot loader configuration files (GRUB)                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `/dev`    | Contains files representing access points to devices on your systems. These include terminal devices (tt&#x79;*), hard disks (hd* or s&#x64;*), RAM (ram*), and CD-ROM(cd\*). Users can access these devices directly through these device files; however, applications often hide the actual device names to end users                                                                                                                                                                                                                                                                                                                           |
| `/etc`    | Contains administrative configuration files. Most of these files are plain-text files that, given the user has proper permission, can be edited with any text editor                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `/home`   | Contains directories assigned to each regular user with a login account. The root user is an exception, using /root as their home directory (see below)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `/media`  | Provides a standard location for automounting devices (removable media in particular). If the medium has a volume name, that name is typically used as the mountpoint. For example, a USB drive with a volume name of myusb would be mounted on `/media/myusb`                                                                                                                                                                                                                                                                                                                                                                                    |
| `/lib`    | Contains shared libraries needed by applications in `/bin` and `/sbin` to boot the system                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `/mnt`    | A common mount point for many devices before it was supplanted by the standard `/media` directory. Some bootable Linux systems still use this directory to mount hard disk partitions and remote filesystems. Many people still use this directory to temporarily mount local or remote filesystems, which are not mounted permanently.                                                                                                                                                                                                                                                                                                           |
| `/misc`   | A directory sometimes used to automount filesystems upon request                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `/opt`    | Directory structure available to store add-on application software                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `/proc`   | Contains information about system resources                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `/root`   | Represents the root user’s home directory. The home directory for root does not reside beneath `/home` for security reasons                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `/sbin`   | Contains administrative commands and daemon processes                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `/sys`    | Contains parameters for such things as tuning block storage and managing cgroups                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `/tmp`    | Contains temporary files used by applications                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `/usr`    | <p>Contains user documentation, games, graphical files (X11), libraries (lib), and a variety of other commands and files that are not needed during the boot process. The <code>/usr</code> directory is meant for files that don’t change after installation. </p><p></p><p>In theory, <code>/usr</code> could be mounted read-only</p>                                                                                                                                                                                                                                                                                                          |
| `/var`    | <p>Contains directories of data used by various applications. In particular, this is where you would place files that you share as an FTP server (<code>/var/ftp</code>) or a webserver (<code>/var/www</code>). It also contains all system log files (<code>/var/log</code>) and spool files in<code>/var/spool</code>(such as mail, cups, and news).</p><p></p><p>The<code>/var</code> directory contains directories and files that are meant to change often. On server computers, it is common to create the <code>/var</code> directory as a <strong>separate filesystem</strong>, using a filesystem type that can be easily expanded</p> |


---

# Agent Instructions: 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://gitbook.hbcomputersecurity.co.uk/core-technical-skills/core-skills/linux/getting-to-know-linux/moving-around-the-filesystem.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.
