TRร„W๐ŸคŸ
TRร„W๐ŸคŸ

@thatstraw

33 Tweets 10 reads May 30, 2022
Linux Directory Structure explained๐Ÿงตโ†“
The Linux Directory Structure is a hierarchical system for organizing Linux directories and files. The Filesystem Hierarchy Standard defines this structure (FHS)
However, some directories in Linux file systems are not yet defined by the standard.
If you're new to Linux or switching from Windows, the Linux file system structure may appear strange and cryptic. C: and other drive letters are no longer available and have been replaced by /.
To help you remember the file system structure, I have made this inphographic, feel free to download and save this image for quick reference to the directory structure in Linux systems.
/- ๐—ง๐—ต๐—ฒ ๐—ฟ๐—ผ๐—ผ๐˜ ๐—ฑ๐—ถ๐—ฟ๐—ฒ๐—ฐ๐˜๐—ผ๐—ฟ๐˜†
The top of the directory structure is the root directory, which is represented by a forward slash (/). The root directory contains the directories and files that make up the Linux system.
You may have come across some internet jokes that mention "rm -rf /." In Linux, the rm command is used to delete files and directories.
With rm -rf /, you are simply instructing your system to delete the contents of the root directory forcefully and recursively. Because the root directory contains everything, you end up deleting everything and your Linux system. So Use this command with caution.
/๐—ฏ๐—ถ๐—ป - ๐—•๐—ถ๐—ป๐—ฎ๐—ฟ๐—ถ๐—ฒ๐˜€
The '/bin' directory contains the majority, if not all, of the machine's programs or applications, such as cd, cat, ls, and so on. The majority of the programs are in binary format and are accessible to all Linux users.
/๐—ฏ๐—ผ๐—ผ๐˜ - ๐—•๐—ผ๐—ผ๐˜ ๐—ณ๐—ถ๐—น๐—ฒ๐˜€
This is an important folder in Linux because it contains all of the files required by the OS to boot, i.e. the boot loaders, such as the file grub.conf found in the grub directory, as well as the set of vmlinuz, initrd, s and kernel related files.
/๐—ฑ๐—ฒ๐˜ƒ - ๐——๐—ฒ๐˜ƒ๐—ถ๐—ฐ๐—ฒ ๐—ณ๐—ถ๐—น๐—ฒ๐˜€
This isย where all your devices live.ย ย You'll find your hardware, such as your keyboard, mouse, andย printer. A ย disk, for example, would be found as /dev/sda, and a partition on that disk would be found as /dev/sda1.
/๐—ฒ๐˜๐—ฐ โ€“ ๐—–๐—ผ๐—ป๐—ณ๐—ถ๐—ด๐˜‚๐—ฟ๐—ฎ๐˜๐—ถ๐—ผ๐—ป ๐—ณ๐—ถ๐—น๐—ฒ๐˜€
The /etc directory houses the system's core configuration files, which are primarily used by the administrator and services, such as the password file, hostnamesย and networking files.
/๐—ต๐—ผ๐—บ๐—ฒ โ€“ ๐—จ๐˜€๐—ฒ๐—ฟ ๐—ฝ๐—ฒ๐—ฟ๐˜€๐—ผ๐—ป๐—ฎ๐—น ๐—ฑ๐—ฎ๐˜๐—ฎ
In Linux, each user is assigned a directory that only they and the system administrator can access. This is the location where you keep your personal files, install programs, and save documents.
In Linux, the HOME directory also contains 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 run the command ls with the -a switch in the terminal.
Assume you have two users on your Linux system, Jerry and Jimmy. They'll have their own home directories at /home/jerry and /home/jimmy respectively.
/๐—น๐—ถ๐—ฏ โ€“ ๐—ฆ๐—ต๐—ฎ๐—ฟ๐—ฒ๐—ฑ ๐—น๐—ถ๐—ฏ๐—ฟ๐—ฎ๐—ฟ๐—ถ๐—ฒ๐˜€
The kernel modules and shared library files required by the system's boot operation can be found in the /lib directory. The extension *.so makes libraries easily identifiable.
In Windows, the equivalent would be a dynamically linked library or DLL.
/๐—บ๐—ฒ๐—ฑ๐—ถ๐—ฎ - ๐— ๐—ผ๐˜‚๐—ป๐˜ ๐—ฝ๐—ผ๐—ถ๐—ป๐˜ ๐—ณ๐—ผ๐—ฟ ๐—ฟ๐—ฒ๐—บ๐—ผ๐˜ƒ๐—ฎ๐—ฏ๐—น๐—ฒ ๐—บ๐—ฒ๐—ฑ๐—ถ๐—ฎ
media directory contains sub-directories in which removable media such as cdroms and USB keys can be mounted on by theย system. You can access the content of the removable media from this directory.
/๐—บ๐—ป๐˜ - ๐— ๐—ผ๐˜‚๐—ป๐˜ ๐—ฑ๐—ถ๐—ฟ๐—ฒ๐—ฐ๐˜๐—ผ๐—ฟ๐˜†
The /mntย directory, like the previously mentioned media folder, is where you (or the system administrator) manually mount devices or filesystems. Mounting is the process of making a filesystem available to the operating system.
/๐—ผ๐—ฝ๐˜ โ€“ ๐—ข๐—ฝ๐˜๐—ถ๐—ผ๐—ป๐—ฎ๐—น ๐˜€๐—ผ๐—ณ๐˜๐˜„๐—ฎ๐—ฟ๐—ฒ
In Linux, the /opt directory is an optional folder that usually contains manually installed software and vendor add-on packages (.i.e not part of the original installation).
/๐—ฝ๐—ฟ๐—ผ๐—ฐ โ€“ ๐—ฃ๐—ฟ๐—ผ๐—ฐ๐—ฒ๐˜€๐˜€ ๐—ฎ๐—ป๐—ฑ ๐—ธ๐—ฒ๐—ฟ๐—ป๐—ฒ๐—น ๐—ณ๐—ถ๐—น๐—ฒ๐˜€
The directory '/proc' contains information about currently running processes and kernel parameters. A number of tools use the content of the proc directory to obtain runtime system information.
In Linux, for example, if you want to check processor information, you can simply navigate to the file /proc/cpuinfo. If you want to see how much memory your Linux system is using, look at the contents of the /proc/meminfo file.
/๐—ฟ๐—ผ๐—ผ๐˜ โ€“ ๐—ง๐—ต๐—ฒ ๐—ต๐—ผ๐—บ๐—ฒ ๐—ฑ๐—ถ๐—ฟ๐—ฒ๐—ฐ๐˜๐—ผ๐—ฟ๐˜† ๐—ผ๐—ณ ๐˜๐—ต๐—ฒ ๐˜‚๐˜€๐—ฒ๐—ฟ
There is also a /root directory, which serves as the root user's home directory. So, instead of /home/root, root's home is at /root. It should not be confused with the root directory (/).
/๐˜€๐—ฏ๐—ถ๐—ป โ€“ ๐—ฆ๐˜†๐˜€๐˜๐—ฒ๐—บ ๐—ฏ๐—ถ๐—ป๐—ฎ๐—ฟ๐—ถ๐—ฒ๐˜€
This is similar to the /bin directory. The only distinction is that it contains binaries that can only be executed by root or a sudo user.
/๐˜๐—บ๐—ฝ โ€“ ๐—ง๐—ฒ๐—บ๐—ฝ๐—ผ๐—ฟ๐—ฎ๐—ฟ๐˜† ๐—ณ๐—ถ๐—น๐—ฒ๐˜€
This directory, as the name implies, stores temporary files. This directory is used by many applications to store temporary files. You can also use a directory to store temporary files.
However, keep in mind that the contents of the /tmp directories are deleted when your system restartsย so don't store 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' 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 stores service data. If you run a server, such as a web server or FTP server, the files that will be accessed by external users would be stored in /srv/.
This should be enough information to help you understand the Linux directory structure and how to use it.
That's it! Thank you for making it this far. Hopefully you will find this thread useful.
Check me out @xtremepentest if you liked this thread!! I'm gonna be tweeting more about Linux, networking, security etc.

Loading suggestions...