TRร„W๐ŸคŸ Profile picture
Nov 26, 2022 โ€ข 36 tweets โ€ข 5 min read โ€ข Read on X
The Linux filesystem and directory structure explained ๐Ÿงโ†“
The Linux Directory Structure is a hierarchical organization system for Linux directories and files. This structure is defined by the Filesystem Hierarchy Standard (FHS)

However, the standard does not yet define some directories in Linux file systems.
If you're new to Linux or switching from Windows, the file system structure of the Linux operating system may appear strange and confusing. C: and other drive letters have been replaced by /.
To help you remember the file system structure, I have made this infographic, feel free to download and save this image for quick reference to the directory structure in Linux systems. Image
๐Ÿง / - ๐—ง๐—ต๐—ฒ ๐—ฟ๐—ผ๐—ผ๐˜ ๐—ฑ๐—ถ๐—ฟ๐—ฒ๐—ฐ๐˜๐—ผ๐—ฟ๐˜†

The root directory, represented by a forward slash (/), is at the top of the directory structure. The root directory contains the directories and files that comprise the Linux system.
You may have seen some internet jokes that reference "rm -rf /." The rm command in Linux is used to delete files and directories.
You are simply instructing your system to delete the contents of the root directory forcefully and recursively with rm -rf /. You end up deleting everything and your Linux system because the root directory contains everything. As a result, use this command with caution.
๐Ÿง /๐—ฏ๐—ถ๐—ป - ๐—•๐—ถ๐—ป๐—ฎ๐—ฟ๐—ถ๐—ฒ๐˜€

The majority, if not all, of the system's programs or applications, such as cd, cat, ls, and so on, are located in the /bin directory. The vast majority of the programs are binary in nature and are available to all Linux users.
๐Ÿง /๐—ฏ๐—ผ๐—ผ๐˜ - ๐—•๐—ผ๐—ผ๐˜ ๐—ณ๐—ถ๐—น๐—ฒ๐˜€

This is an important folder in Linux because it contains all of the files needed by the operating system to boot, such as the boot loaders, such as the file grub.conf found in the grub directory,....
.....as well as the set of vmlinuz, initrd, and kernel related files.
๐Ÿง /๐—ฑ๐—ฒ๐˜ƒ - ๐——๐—ฒ๐˜ƒ๐—ถ๐—ฐ๐—ฒ ๐—ณ๐—ถ๐—น๐—ฒ๐˜€

This is where all of your devices are stored. Your hardware, such as your keyboard, mouse, and printer, can be found here. A disk, for example, would be identified as /dev/sda, and a partition on that disk as /dev/sda1.
๐Ÿง /๐—ฒ๐˜๐—ฐ - ๐—–๐—ผ๐—ป๐—ณ๐—ถ๐—ด๐˜‚๐—ฟ๐—ฎ๐˜๐—ถ๐—ผ๐—ป ๐—ณ๐—ถ๐—น๐—ฒ๐˜€

The /etc directory contains the system's core configuration files, such as the password file, hostnames, and networking files, which are primarily used by the administrator and services.
๐Ÿง /๐—ต๐—ผ๐—บ๐—ฒ - ๐—จ๐˜€๐—ฒ๐—ฟ ๐—ฝ๐—ฒ๐—ฟ๐˜€๐—ผ๐—ป๐—ฎ๐—น ๐—ฑ๐—ฎ๐˜๐—ฎ

Each user in Linux is assigned a directory that only they and the system administrator have access to. This is where you save personal files, install programs, and save documents.
The HOME directory in Linux also stores your personal configuration files, also known as dot files (a dot precedes the name of the file).
These are typically 'hidden,' and in order to see them, you must enable the appropriate option in your file manager or use the terminal command ls with the -a option.
Assume you have two users named foo and bar on your Linux system. They'll each have their own home directories at /home/foo and /home/bar.
๐Ÿง /๐—น๐—ถ๐—ฏ - ๐—ฆ๐—ต๐—ฎ๐—ฟ๐—ฒ๐—ฑ ๐—น๐—ถ๐—ฏ๐—ฟ๐—ฎ๐—ฟ๐—ถ๐—ฒ๐˜€

The /lib directory contains the kernel modules and shared library files required for the system to boot. Libraries are easily identified by the extension *.so.
In Windows, the equivalent would be a dynamically linked library or DLL.
๐Ÿง /๐—บ๐—ฒ๐—ฑ๐—ถ๐—ฎ - ๐— ๐—ผ๐˜‚๐—ป๐˜ ๐—ฝ๐—ผ๐—ถ๐—ป๐˜ ๐—ณ๐—ผ๐—ฟ ๐—ฟ๐—ฒ๐—บ๐—ผ๐˜ƒ๐—ฎ๐—ฏ๐—น๐—ฒ ๐—บ๐—ฒ๐—ฑ๐—ถ๐—ฎ

The media directory contains subdirectories in which the system can mount removable media such as CDs and USB keys. This directory provides access to the contents of removable media.
๐Ÿง /๐—บ๐—ป๐˜ - ๐— ๐—ผ๐˜‚๐—ป๐˜ ๐—ฑ๐—ถ๐—ฟ๐—ฒ๐—ฐ๐˜๐—ผ๐—ฟ๐˜†

Like the previously mentioned media folder, the /mnt directory is where you (or the system administrator) manually mount devices or filesystems. The process of making a filesystem available to the operating system is known as mounting.
๐Ÿง /๐—ผ๐—ฝ๐˜ - ๐—ข๐—ฝ๐˜๐—ถ๐—ผ๐—ป๐—ฎ๐—น ๐˜€๐—ผ๐—ณ๐˜๐˜„๐—ฎ๐—ฟ๐—ฒ

The /opt directory in Linux is an optional folder that typically contains manually installed software as well as vendor add-on packages (.i.e not part of the original installation).
๐Ÿง /๐—ฝ๐—ฟ๐—ผ๐—ฐ - ๐—ฃ๐—ฟ๐—ผ๐—ฐ๐—ฒ๐˜€๐˜€ ๐—ฎ๐—ป๐—ฑ ๐—ธ๐—ฒ๐—ฟ๐—ป๐—ฒ๐—น ๐—ณ๐—ถ๐—น๐—ฒ๐˜€

The '/proc' directory contains information about currently running processes and kernel parameters. A number of tools obtain runtime system information from the contents of the proc directory.
If you want to check processor information in Linux, for example, go to the file /proc/cpuinfo. Examine the contents of the /proc/meminfo file to see how much memory your Linux system is using.
๐Ÿง /๐—ฟ๐—ผ๐—ผ๐˜ - ๐—ง๐—ต๐—ฒ ๐—ต๐—ผ๐—บ๐—ฒ ๐—ฑ๐—ถ๐—ฟ๐—ฒ๐—ฐ๐˜๐—ผ๐—ฟ๐˜† ๐—ผ๐—ณ ๐˜๐—ต๐—ฒ ๐˜‚๐˜€๐—ฒ๐—ฟ

There is also a /root directory, which serves as the home directory for the root user. As a result, rather than /home/root, root's home is at /root. It is not the same as the root directory (/).
๐Ÿง /๐˜€๐—ฏ๐—ถ๐—ป - ๐—ฆ๐˜†๐˜€๐˜๐—ฒ๐—บ ๐—ฏ๐—ถ๐—ป๐—ฎ๐—ฟ๐—ถ๐—ฒ๐˜€

This is analogous to the /bin directory. The only difference is that it includes binaries that can only be run by root or a sudo user.
๐Ÿง /๐˜๐—บ๐—ฝ - ๐—ง๐—ฒ๐—บ๐—ฝ๐—ผ๐—ฟ๐—ฎ๐—ฟ๐˜† ๐—ณ๐—ถ๐—น๐—ฒ๐˜€

As the name implies, this directory stores temporary files. Many applications use this directory to store temporary files. A directory can also be used to store temporary files.
Keep in mind, however, that the contents of the /tmp directories are deleted when your system restarts, so don't save anything important here.
๐Ÿง /๐˜‚๐˜€๐—ฟ โ€“ ๐—จ๐˜€๐—ฒ๐—ฟ ๐—ฏ๐—ถ๐—ป๐—ฎ๐—ฟ๐—ถ๐—ฒ๐˜€ ๐—ฎ๐—ป๐—ฑ ๐—ฝ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ ๐—ฑ๐—ฎ๐˜๐—ฎ

Here you can find executable files, libraries, source of most of the system programs.

Here are some examples of directories contained in the /usr directory
- /usr/bin - contains basic user commands
- /usr/sbin - contains administrator-specific commands.
- /usr/lib - contains the system libraries
- /usr/share - contains documentation or files that are shared by all libraries, such as '/usr/share/man', which contains the text of the manpages.
๐Ÿง /๐˜ƒ๐—ฎ๐—ฟ - ๐—ฉ๐—ฎ๐—ฟ๐—ถ๐—ฎ๐—ฏ๐—น๐—ฒ ๐—ฑ๐—ฎ๐˜๐—ฎ ๐—ณ๐—ถ๐—น๐—ฒ๐˜€

'/var' directory contains variable data that is expected to grow in size (such as system logging files, printer spool directories, mail, and so on).
For example:

โ€“ /var/crash - stores information about crashed processes.
โ€“ /var/log - contains log files for the system as well as other applications.
โ€“ /var/lib - contains dynamic data files/libraries.
โ€“ /var/spool - spool data of applications.
โ€“ /var/mail - contains user mailbox files.
๐Ÿง /๐˜€๐—ฟ๐˜ƒ - ๐—ฆ๐—ฒ๐—ฟ๐˜ƒ๐—ถ๐—ฐ๐—ฒ ๐—ฑ๐—ฎ๐˜๐—ฎ

This is the service directory, which contains information about the services. If you run a server, such as a web server or FTP server, the files accessed by external users will be stored in /srv/.
This information should be sufficient to help you understand the Linux directory structure and how to use it.

That's all! Thank you for getting this far. I hope you find this thread useful.
If you found this thread valuable:

1. Toss us a follow for more daily threads on Linux, sysadmin and security โ†’ @xtremepentest

2. Like and RT the first tweet so other Linux folks can find it too.

โ€ข โ€ข โ€ข

Missing some Tweet in this thread? You can try to force a refresh
ใ€€

Keep Current with TRร„W๐ŸคŸ

TRร„W๐ŸคŸ Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @thatstraw

Jul 11, 2024
Linux filesystem and directory structure๐Ÿง

๐Ÿ“ /
โ”œโ”€โ”€ ๐Ÿ“ bin
โ”‚ โ”œโ”€โ”€ โš™๏ธ ls
โ”‚ โ””โ”€โ”€ โš™๏ธ bash
โ”œโ”€โ”€ ๐Ÿ“ boot
โ”‚ โ”œโ”€โ”€ ๐Ÿ’พ vmlinuz
โ”‚ โ””โ”€โ”€ ๐Ÿ’พ initrd.img
โ”œโ”€โ”€ ๐Ÿ“ dev
โ”‚ โ”œโ”€โ”€ ๐Ÿ’ฟ sda1
โ”‚ โ””โ”€โ”€ ๐Ÿ’ฟ sdb
โ”œโ”€โ”€ ๐Ÿ“ etc
โ”‚ โ”œโ”€โ”€ ๐Ÿ› ๏ธ passwd
โ”‚ โ””โ”€โ”€ ๐Ÿ› ๏ธ fstab
โ”œโ”€โ”€ ๐Ÿ“ home
โ”‚ โ”œโ”€โ”€ ๐Ÿ“ james
โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ› ๏ธ .bashrc
โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ“ documents
โ”‚ โ”‚ โ””โ”€โ”€ ๐Ÿ“ .ssh
โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ” id_rsa
โ”‚ โ”‚ โ””โ”€โ”€ ๐Ÿ”‘ authorized_keys
โ”‚ โ””โ”€โ”€ ๐Ÿ“ traw
โ”‚ โ”œโ”€โ”€ ๐Ÿ› ๏ธ .profile
โ”‚ โ”œโ”€โ”€ ๐Ÿ“ pictures
โ”‚ โ””โ”€โ”€ ๐Ÿ“ .ssh
โ”‚ โ”œโ”€โ”€ ๐Ÿ” id_rsa
โ”‚ โ””โ”€โ”€ ๐Ÿ”‘ authorized_keys
โ”œโ”€โ”€ ๐Ÿ“ lib
โ”‚ โ”œโ”€โ”€ โš™๏ธ
โ”‚ โ””โ”€โ”€ โš™๏ธ
โ”œโ”€โ”€ ๐Ÿ“ media
โ”‚ โ”œโ”€โ”€ ๐Ÿ“ cdrom
โ”‚ โ””โ”€โ”€ ๐Ÿ“ usb
โ”œโ”€โ”€ ๐Ÿ“ mnt
โ”‚ โ””โ”€โ”€ ๐Ÿ“ mymount
โ”œโ”€โ”€ ๐Ÿ“ opt
โ”‚ โ””โ”€โ”€ ๐Ÿ“ myapp
โ”œโ”€โ”€ ๐Ÿ“ proc
โ”‚ โ”œโ”€โ”€ ๐Ÿ“„ cpuinfo
โ”‚ โ””โ”€โ”€ ๐Ÿ“„ meminfo
โ”œโ”€โ”€ ๐Ÿ“ root
โ”‚ โ”œโ”€โ”€ ๐Ÿ› ๏ธ .bash_history
โ”‚ โ””โ”€โ”€ ๐Ÿ“ .ssh
โ”‚ โ”œโ”€โ”€ ๐Ÿ” id_rsa
โ”‚ โ””โ”€โ”€ ๐Ÿ”‘ authorized_keys
โ”œโ”€โ”€ ๐Ÿ“ run
โ”‚ โ”œโ”€โ”€ ๐Ÿ“„ utmp
โ”‚ โ””โ”€โ”€ ๐Ÿ“„ systemd
โ”œโ”€โ”€ ๐Ÿ“ sbin
โ”‚ โ”œโ”€โ”€ โš™๏ธ init
โ”‚ โ””โ”€โ”€ โš™๏ธ reboot
โ”œโ”€โ”€ ๐Ÿ“ srv
โ”‚ โ””โ”€โ”€ ๐Ÿ“ myservice
โ”œโ”€โ”€ ๐Ÿ“ sys
โ”‚ โ”œโ”€โ”€ ๐Ÿ“„ devices
โ”‚ โ””โ”€โ”€ ๐Ÿ“„ firmware
โ”œโ”€โ”€ ๐Ÿ“ tmp
โ”‚ โ”œโ”€โ”€ ๐Ÿ“„ temp1
โ”‚ โ””โ”€โ”€ ๐Ÿ“„ temp2
โ”œโ”€โ”€ ๐Ÿ“ usr
โ”‚ โ”œโ”€โ”€ ๐Ÿ“ bin
โ”‚ โ”‚ โ”œโ”€โ”€ โš™๏ธ perl
โ”‚ โ”‚ โ””โ”€โ”€ โš™๏ธ python
โ”‚ โ”œโ”€โ”€ ๐Ÿ“ lib
โ”‚ โ”‚ โ”œโ”€โ”€ โš™๏ธ
โ”‚ โ”‚ โ””โ”€โ”€ โš™๏ธ
โ”‚ โ””โ”€โ”€ ๐Ÿ“ local
โ”‚ โ”œโ”€โ”€ ๐Ÿ“ bin
โ”‚ โ”œโ”€โ”€ ๐Ÿ“ lib
โ”‚ โ””โ”€โ”€ ๐Ÿ“ share
โ””โ”€โ”€ ๐Ÿ“ var
โ”œโ”€โ”€ ๐Ÿ“ log
โ”‚ โ”œโ”€โ”€ ๐Ÿ“„ syslog
โ””โ”€โ”€ ๐Ÿ“„ auth.log
โ”œโ”€โ”€ ๐Ÿ“ mail
โ”œโ”€โ”€ ๐Ÿ“ run
โ”œโ”€โ”€ ๐Ÿ“ spool
โ””โ”€โ”€ ๐Ÿ“ wwwlibc.so
libm.so
libssl.so
libcrypto.so
๐Ÿ“ / (Root Directory)
โ€ข The top-level directory of the filesystem. All other directories and files are contained within this directory.

๐Ÿ“ /bin
โ€ข Contains essential binary executables (commands like ls, bash). These are the basic commands needed for system operation.
๐Ÿ“ /boot
โ€ข Contains the boot loader files and kernel images (e.g., vmlinuz, initrd.img). These files are necessary to start the operating system.

๐Ÿ“ /dev
โ€ข Contains device files representing hardware devices (e.g., sda1, tty). These special files allow software to interact with hardware devices.
Read 10 tweets
Jul 9, 2024
REST API Design Image
Looking for a tool that simplifies API management? Introducing Apidog

Designing APIs can be complex, but tools like @ApidogHQ simplify the process. Apidog ( is a comprehensive API design-first development platform that offers numerous features to streamline API development. While many API design and management tools are available, Apidog stands out as a comprehensive solution.

You can check out and try Apidog using this link:
apidog.com/?utm_source=thโ€ฆImage
Here's why Apidog is becoming the go-to platform for API design:

1. REAL API Design-first Development Platform

Apidog offers visual tools for API design, development, testing, and documentation. Its elegant UI and compatibility with OpenAPI Specification (OAS) eliminate the need for manual coding.

The platform also supports multi-branch API development, making it ideal for teams working on complex projects.Image
Read 8 tweets
Jun 4, 2024
If you want to learn Linux bash scripting for FREE, open this: Image
1. Getting Started with Bash Scripting

Bash scripts are a series of commands written in a file that can be executed by the Bash shell. This article will cover the basics of creating and running your first Bash script.
sysxplore.com/create-a-bash-โ€ฆ
2. Comments in Bash

Commenting your code is an essential practice in programming, as it helps you and others understand the purpose and functionality of each section.

In Bash scripting, comments are used to annotate your scripts, making them more readable and maintainable. This article will cover the different ways to add comments in your Bash scripts.
sysxplore.com/comments-in-baโ€ฆ
Read 19 tweets
Dec 29, 2023
Linux hand-written notes:๐Ÿงต โ†“ Image
[2] Image
[3] Image
Read 80 tweets
Oct 24, 2023
13 Linux tr command practical examples you should know as a system administrator: Image
The tr command short for translate, is one of the most useful command for manipulating text on the command line.
It allows you to perform useful operations such as converting lowercase characters to uppercase characters, uppercase characters to lowercase characters, character replacing, and deleting characters.

It is usually used in conjunction with other commands via piping.
Read 29 tweets
Jul 2, 2023
Linux user management - how to add users in Linux ๐Ÿงตโ†“
The useradd command is the main tool for adding new users to a Linux system. This command allows you to quickly create a new user account and configure the user's $HOME directory structure.
The useradd command creates a user account by combining system default settings and command-line parameters.

To see the system default values on your Linux distribution, use the useradd command with the -D option:

$ useradd -D
Read 18 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(