- User mailbox files (optional)
- 5.11.1. Purpose
- Rationale
- /tmp – Temporary Files
- /proc – Kernel Files
- Type of Files in Linux
- Essential Commands for Navigating the Shell
- mkdir:
- touch:
- ls:
- pwd:
- cd:
- less:
- cat:
- cp:
- mv:
- rmdir:
- rm:
- Usr directory
- User home directories (optional)
- 3.8.1. Purpose
- 3.8.2. Requirements
- 3.8.3. Home Directory Specifications and Conventions
- Host-specific system configuration
- 3.7.1. Purpose
- 3.7.2. Requirements
- 3.7.3. Specific Options
- 3.7.4. /etc/opt : Configuration files for /opt
- 3.7.4.1. Purpose
- 3.7.4.2. Requirements
- Rationale
- 3.7.5. /etc/X11 : Configuration for the X Window System (optional)
- 3.7.5.1. Purpose
- 3.7.5.2. Specific Options
- 3.7.6. /etc/sgml : Configuration files for SGML (optional)
- 3.7.6.1. Purpose
- 3.7.7. /etc/xml : Configuration files for XML (optional)
- 3.7.7.1. Purpose
- Variable state information
- 5.8.1. Purpose
- 5.8.2. Requirements
- 5.8.3. Specific Options
- 5.8.4. /var/lib/<editor> : Editor backup files and state (optional)
- 5.8.4.1. Purpose
- Rationale
- 5.8.5. /var/lib/color : Color management information (optional)
- 5.8.5.1. Purpose
- 5.8.6. /var/lib/hwclock : State directory for hwclock (optional)
- 5.8.6.1. Purpose
- Rationale
- 5.8.7. /var/lib/misc : Miscellaneous variable data
- 5.8.7.1. Purpose
- Bin directory
- / – The Root
- Requirements
- Shell, Terminal, Command Line, Command Prompt
- Mnt directory
- Chapter 4. The /usr Hierarchy
- /lost+found
- System binaries
- 3.16.1. Purpose
- 3.16.2. Requirements
- 3.16.3. Specific Options
- /opt
- Purpose
- Commands and flags
- Sbin directory
- /usr/local
- 4.9.1. Purpose
- 4.9.2. Requirements
- 4.9.3. Specific Options
- Rationale
- Rationale
- 4.9.4. /usr/local/share : Local architecture-independent hierarchy
- Static files of the boot loader
- 3.5.1. Purpose
- 3.5.2. Specific Options
- Lib directory
- Essential user command binaries (for use by all users)
- 3.4.1. Purpose
- 3.4.2. Requirements
- Rationale
- 3.4.3. Specific Options
- Rationale
- Dev directory
- /snap
- /usr – User Binaries
- Application cache data
- 5.5.1. Purpose
- Rationale
- 5.5.2. Specific Options
- 5.5.3. /var/cache/fonts : Locally-generated fonts (optional)
- 5.5.3.1. Purpose
- 5.5.3.2. Specific Options
- 5.5.4. /var/cache/man : Locally-formatted manual pages (optional)
- 5.5.4.1. Purpose
- Rationale
- Directories and files
- Lib32
- /usr
- Variable data for /opt
- 5.12.1. Purpose
- Rationale
- Specific Options
- /etc
- Var directory
- Directory for standard include files.
- 4.5.1. Purpose
- 4.5.2. Specific Options
- Application spool data
- 5.14.1. Purpose
- 5.14.2. Specific Options
- 5.14.3. /var/spool/lpd : Line-printer daemon print queues (optional)
- 5.14.3.1. Purpose
- 5.14.3.2. Specific Options
- 5.14.4. /var/spool/rwho : Rwhod files (optional)
- 5.14.4.1. Purpose
- Rationale
- Requirements
- /dev – Device Nodes
- Device files
- 3.6.1. Purpose
- 3.6.2. Specific Options
- Alternate format essential shared libraries (optional)
- 3.10.1. Purpose
- 3.10.2. Requirements
- /lost+found – Recovered Files
- /media – Automatic mount point
- /sys
- Purpose
- Specific Options
- /var
- Run-time variable data
- 3.15.1. Purpose
- 3.15.2. Requirements
- /srv – Service Data
- /var/lock
- 5.9.1. Purpose
- Data for services provided by this system
- 3.17.1. Purpose
- Rationale
- Run directory
- Temporary files preserved between system reboots
- 5.15.1. Purpose
- /sbin
- Purpose
- Rationale
- Rationale
- Lib64
- Linux Environment Variables
- The $PATH Variable
- /dev
- /tmp
- Libraries for programming and packages
- 4.6.1. Purpose
- 4.6.2. Specific Options
- /root
- /lib – Libraries
- Run-time variable data
- 5.13.1. Purpose
- 5.13.2. Requirements
- /sbin – System Binaries
- Add-on application software packages
- 3.13.1. Purpose
- 3.13.2. Requirements
- Rationale
- Non-essential standard system binaries
- 4.10.1. Purpose
- 4.10.2. Requirements
- Home directory
- Alternate format libraries (optional)
- 4.8.1. Purpose
- Proc directory
- Understand the Key Terminologies
- Network Information Service (NIS) database files (optional)
- 5.16.1. Purpose
- Rationale
- Binaries run by other programs (optional)
- 4.7.1. Purpose
- Rationale
- /mnt
- The difference
- 1. Different directory levels:
- 2. The time of catalog generation is different:
- 3. Different file permissions:
- /etc – Configuration Files
- Chapter 6. Operating System Specific Annex
- /boot – Boot Files
- Linux Root folders
- Linux
- 6.1.1. / : Root directory
- 6.1.2. /bin : Essential user command binaries (for use by all users)
- 6.1.3. /dev : Devices and special files
- Rationale
- 6.1.4. /etc : Host-specific system configuration
- 6.1.5. /proc : Kernel and process information virtual filesystem
- 6.1.6. /sbin : Essential system binaries
- 6.1.7. /sys : Kernel and system information virtual filesystem
- 6.1.8. /usr/include : Header files included by C programs
- 6.1.9. /usr/src : Source code
- Note
- Rationale
- 6.1.10. /var/spool/cron : cron and at jobs
- /root – Root Home
- Boot directory
- /home – Users’ Folder
- Log files and directories
- 5.10.1. Purpose
- 5.10.2. Specific Options
- Process accounting logs (optional)
- 5.4.1. Purpose
- /run – Early temp
- /run
- Scope
- /opt – Optional Software
- Conventions
- /home
- Swapfile (not a directory)
- Home directory for the root user (optional)
- 3.14.1. Purpose
- /var – Variable Files
- Dedication
- Tmp directory
- Chapter 5. The /var Hierarchy
- Chapter 2. The Filesystem
- Rationale
- General Guidelines
- Specific Options
- Chapter 3. The Root Filesystem
- 2, the root directory refers to the top directory, which is «/»
- Snap directory
- /bin – Binaries
- /mnt – Manual mount point
- Most user commands
- 4.4.1. Purpose
- 4.4.2. Requirements
- 4.4.3. Specific Options
- Rationale
- System crash dumps (optional)
- 5.6.1. Purpose
- 1, the home directory is the user’s / home directory, which is divided into two cases
- (1), ordinary users
- (2), root user
- / ( Root Directory)
- Essential shared libraries and kernel modules
- 3.9.1. Purpose
- 3.9.2. Requirements
- 3.9.3. Specific Options
- /media
- Etc directory
- /bin
- Temporary files
- 3.18.1. Purpose
- Rationale
- Requirements
- /proc
- 3, how to switch between ordinary users and root users
- (1), ordinary user → root user
- (2), root user → ordinary user
- /boot
- Mount point for removable media
- 3.11.1. Purpose
- Rationale
- 3.11.2. Specific Options
- Contributors
- Opt directory
- / directory
- Variable game data (optional)
- 5.7.1. Purpose
- Rationale
- Source code (optional)
- 4.12.1. Purpose
- Mount point for a temporarily mounted filesystem
- 3.12.1. Purpose
- Operating system
- Linux Vs Unix
- Ubuntu:
- /lib,/lib64
- /srv (Service directory)
- Purpose
User mailbox files (optional)
5.11.1. Purpose
Rationale
It is important to note that there is no requirement to
physically move the mail spool to this location. However, programs
and header files must be changed to use
/var/mail.
/tmp – Temporary Files
This is just a place where programs store temporary files on your system. This directory is usually cleaned on reboot.

/proc – Kernel Files
This is a virtual file-system maintained by the Linux kernel. Usually, you do not touch anything in this folder. It is needed only for the kernel to run different processes.

Type of Files in Linux
In Linux and UNIX systems, everything is considered a file. If not, then it’s a running process. Generally, all files in Linux fall into either of these three categories.
- Regular files: These include text files, photos, videos, programs, and executable files.
- Directories: This might sound a bit strange, but in Linux, directories are also considered files since they provide storage for other files and subdirectories.
- Special files: These are device files that comprise symbolic links, block files, socket files, and named pipe files.
That said, let us now examine the Linux File System Tree in more detail.
Essential Commands for Navigating the Shell
Navigating the shell is an essential skill for anyone working in a Linux environment. It allows us to move between directories, create new files and directories, and manage existing ones. In this section, we will cover some common commands and their flags that you can use to navigate the shell with ease.
mkdir:
The mkdir command is used to create a new directory.

We can also create multiple directories at the same time.
Take, for instance, creating «mydir1», «mydir2», and «mydir3» at the same time:

touch:
The touch command is used to create a new file.

And To create «file2», and «file3» at the same time, we use this command:

ls:
The ls command is used to list the contents of a directory.
Let’s list the content of the /test directory and see the files that we have created using touch and the directories that we have created using mkdir:

As we can see in /test directory we have 4 directories and 3 files.
To list the content of the current working directory in a detailed, long format. We add «-l» flag to ls which displays additional information about each file, such as the file size, owner, and permissions(which will be covered in the next blogs).
Trying it on our /test directory will give us a better understanding:

ls -aAnd to display all files including hidden files in the current working directory in long format. we use this command:
ls -laLet’s create some hidden files using the touch command and hidden directories using mkdir. Then try the ls command and ls with flags and observe the result. To create a hidden file or directory we add a («.») dot before the name of the file or directory.

From the example above we can clearly see that:
ls: Lists the contents of the current directory (in this case, /test) without showing hidden files and hidden directories.
ls -l: Lists the contents of the current directory in the long format, which includes details such as file permissions, ownership, size, and date modified, but does not show hidden files and hidden directories.
ls -a: Lists all contents of the current directory, including hidden files and hidden directories (whose names begin with a dot, e.g. .hidden_file1, .hidden_dir1).
ls -la: Lists all contents of the current directory in the long format, including hidden files and hidden directories.
pwd:
The pwd command is used to display the current working directory.
To demonstrate, the pwd displayed our working directory which is /test.

cd:
For example, let’s move from /test to «mydir» directory, and use pwd to check our current directory.

«cd ..»: This command is used to move one directory level up from the current working directory.
For instance, we are now in «mydir» to move up to its parent directory, we type «cd ..»

«cd -«: This command is used to move to the previous working directory.
As an illustration, we were previously in «mydir» and using «cd ..» we move up to its parent directory /test, to switch back to the previous directory «mydir» we use «cd -«.

less:
This command is used to view the contents of a file.

when we press Enter this is what we get:

To return to the terminal we press the «q» key.
cat:
This command is used to print the content of the file in the terminal.
Let’s print the content of file1 in the terminal:

The cat command is also used to concatenate files and print their contents in the terminal.
Let’s add some contents to «file2» and use cat to print the contents of file1 and file2 at the same time.

cp:
The cp command is used to copy files and directories. Here are some examples of how to use the cp command:
cp source_file destination_fileAs an example, Let’s copy the contents of file1 to file3 and use the cat command to compare their contents:

— To copy a file to a directory, we use this syntax:
cp file_to_copy destination_directoryAs an instance, let’s copy «file2» inside «mydir»

cp -r directory_to_copy destination_directoryFor example, let’s create some directories and files inside «mydir1» and copy «mydir1» inside «mydir».

mv:
This command is used to move or rename files or directories. Here are some examples of how to use the mv command:
mv file_to_move destination_directoryTo demonstrate, let’s move «file3» to «mydir2»:

mv directory_to_move destination_directoryFor instance, let’s move «mydir2» to «mydir»:

mv old_file_name new_file_nameFor example, let’s change the name of «file2» to «file2_updated»:

Note: When renaming a file, it’s important to note that if the new file name already exists in the current directory, the «mv» command will move the contents of the file inside the existing file with the same name. The same rule applies to directories as well. For instance, if you have two directories called «mydir» and «newdir» and you try to rename «mydir» to «newdir», the «mv» command will move «mydir» inside «newdir». To prevent this from happening, it’s crucial to ensure that the new file or directory name is unique within the current directory. You can use the «ls» command to list the contents of the directory and check for existing names if you are unsure.


rmdir:
This command is used to delete an empty directory.
As an illustration, let’s delete the empty directory mydir3.

Note: We can not delete a directory with contents using rmdir.
As an example, we could not delete «mydir» using rmdir because «mydir» is not empty.

rm:
This command is used to remove files and directories.
rm file_nameLet’s try this command by removing «file1» from the «test» directory:

— To remove a nonempty directory called, we use use the syntax below:
rm -r directory_nameFor example, let’s remove «mydir» directory from «test» directory.

Let’s now try to remove «mydir» from the «test» directory using -i flag:

To sum up, this mind map provides a concise summary of the navigation commands that we have covered in this blog:

Excellent job on reaching this point! In this blog, we have covered the key terminologies that are often confusing for beginners, such as operating systems, Linux and Unix, Ubuntu, shell, terminal, command line, and command prompt. We have also discussed directories and files and the file system hierarchy, which is the structure of how files and directories are organized on our computer. By mastering the concepts covered in this blog, you will be well on your way to become proficient in shell navigation. Don’t forget to practice and explore more commands to enhance your skills.
Usr directory

/usr/lib: Contains libraries for programs stored in/usr/binand/usr/sbin.
Note: I don’t wanna go too deep into this as it may get overwhelming.
User home directories (optional)
3.8.1. Purpose
3.8.2. Requirements
3.8.3. Home Directory Specifications and Conventions
Host-specific system configuration
3.7.1. Purpose
It is recommended that files be stored in subdirectories of
/etc rather than directly in
/etc.
3.7.2. Requirements
No binaries may be located under
/etc.
3.7.3. Specific Options
3.7.4. /etc/opt : Configuration files for /opt
3.7.4.1. Purpose
Host-specific configuration files for add-on application
software packages must be installed within the directory
/etc/opt/<subdir>, where
<subdir> is the name of the subtree in
/opt where the static data from that package is
stored.
3.7.4.2. Requirements
No structure is imposed on the internal arrangement of
/etc/opt/<subdir>.
If a configuration file must reside in a different location in
order for the package or system to function properly, it may be placed
in a location other than
/etc/opt/<subdir>.
Rationale
Refer to the rationale for /opt.
3.7.5. /etc/X11 : Configuration for the X Window System (optional)
3.7.5.1. Purpose
is the location for all X11
host-specific configuration. This directory is necessary to allow
local control if is mounted read
only.
3.7.5.2. Specific Options
3.7.6. /etc/sgml : Configuration files for SGML (optional)
3.7.6.1. Purpose
Generic configuration files defining high-level parameters of
the SGML systems are installed here. Files with names
*.conf indicate generic configuration files.
File with names *.cat are the DTD-specific
centralized catalogs, containing references to all other catalogs
needed to use the given DTD. The super catalog file
catalog references all the centralized
catalogs.
3.7.7. /etc/xml : Configuration files for XML (optional)
3.7.7.1. Purpose
Generic configuration files defining high-level parameters of
the XML systems are installed here. Files with names
*.conf indicate generic configuration files.
The super catalog file
catalog references all the centralized
catalogs.
Variable state information
5.8.1. Purpose
State information is generally used to preserve the condition of
an application (or a group of inter-related applications) between
invocations and between different instances of the same application.
State information should generally remain valid after a reboot, should
not be logging output, and should not be spooled data.
/var/lib/<name> is the location that
must be used for all distribution packaging support. Different
distributions may use different names, of course.
5.8.2. Requirements
5.8.3. Specific Options
5.8.4. /var/lib/<editor> : Editor backup files and state (optional)
5.8.4.1. Purpose
These directories contain saved files generated by any
unexpected termination of an editor (e.g., ,
, ).
Other editors may not require a directory for crash-recovery
files, but may require a well-defined place to store other information
while the editor is running. This information should be stored in a
subdirectory under /var/lib (for example, GNU
Emacs would place lock files in
/var/lib/emacs/lock).
Future editors may require additional state information beyond
crash-recovery files and lock files — this information should
also be placed under
/var/lib/<editor>.
Rationale
Previous Linux releases, as well as all commercial vendors, use
/var/preserve for vi or its clones. However,
each editor uses its own format for these crash-recovery files, so a
separate directory is needed for each editor.
Editor-specific lock files are usually quite different from the
device or resource lock files that are stored in
/var/lock and, hence, are stored under
/var/lib.
5.8.5. /var/lib/color : Color management information (optional)
5.8.5.1. Purpose
5.8.6. /var/lib/hwclock : State directory for hwclock (optional)
5.8.6.1. Purpose
This directory contains the file
/var/lib/hwclock/adjtime.
Rationale
In FHS 2.1, this file was /etc/adjtime, but
as updates it, that was obviously
incorrect.
5.8.7. /var/lib/misc : Miscellaneous variable data
5.8.7.1. Purpose
Bin directory
This directory contains binaries (binary files) of the programs that are installed on the current Operating system as well as core utility files required for the operating system to work properly. It also contains terminal commands such as ls, cd, mv, cp, and more.
/ – The Root
Everything begins in your system from this directory. All your folders, hard drives, USB drivers, everything is located in this root folder. You cannot go above this directory.
Also, the root directory is designated by the slash sign.

This Linux Directory Structure may look like a mess, but believe me when you learn it, you will realize how much sense it makes.
Requirements
Shell, Terminal, Command Line, Command Prompt
There is often confusion around the terms terminal, shell, command line, and command prompt, leading some to believe they all mean the same thing. But, do they actually mean the same thing? Let’s explore and clarify the relationship between these terms.
Mnt directory
/mnt is also a directory that is commonly used as a mount point for temporarily mounting file systems or storage devices. The acronym «mnt» stands for «mount» and this directory is typically used to mount various file systems such as removable media (e.g. USB drives, CD/DVDs), network file systems, and other local file systems.
Note: Both /mnt and /media directories are used as mount points for temporarily mounting file systems or storage devices. However, there is a slight difference in their usage and conventions.
Chapter 4. The /usr Hierarchy
/lost+found
This is a directory that is mostly found in Ubuntu and Ubuntu-based distributions. It’s a special directory that contains obsoleted data. These are fragments of files that have either been deleted or lost during disk operation.
System binaries
3.16.1. Purpose
3.16.2. Requirements
There must be no subdirectories in /sbin.
3.16.3. Specific Options
/opt
The /opt directory contains add-on applications or software packages that are provided by a third-party vendor and are not installed through your operating system package manager. Each such application has its own subdirectory which contains all the essential files needed for it to run.
When you install a software package from a third-party repository, or compile software binaries yourself, the files are stored in the /opt directory.

Purpose
This standard enables:
Software to predict the location of installed files and
directories, and
We do this by:
Specifying guiding principles for each area of the filesystem,
Specifying the minimum files and directories required,
Enumerating exceptions to the principles, and
Enumerating specific cases where there has been historical conflict.
The FHS document is used by:
Independent software suppliers to create applications which are FHS
compliant, and work with distributions which are FHS compliant,OS creators to provide systems which are FHS compliant, and
The FHS document has a limited scope:
FHS addresses issues where file placements need to be coordinated
between multiple parties such as local sites, distributions,
applications, documentation, etc.
Commands and flags
A command is an instruction given to a computer program to perform a particular operation or task. For example, «ls» is a command that lists the files and directories in the current working directory.
Sbin directory

/usr/local
4.9.1. Purpose
4.9.2. Requirements
No other directories, except those listed below, may be in
/usr/local after first installing a FHS-compliant
system.
4.9.3. Specific Options
If directories /lib or<qual>
/usr/lib exist, the equivalent<qual>
directories must also exist in /usr/local.
/usr/local/etc may be a symbolic link to
/etc/local.
Rationale
The consistency of /usr/local/etc is
beneficial to installers, and is already used in other systems. As
all of /usr/local needs to be backed up to
reproduce a system, it introduces no additional maintenance overhead,
but a symlink to /etc/local is suitable if
systems want all their configuration under one hierarchy.
Note that /usr/etc is still not allowed: programs
in /usr should place configuration files in
/etc.
Rationale
4.9.4. /usr/local/share : Local architecture-independent hierarchy
Static files of the boot loader
3.5.1. Purpose
Programs necessary to arrange for the boot loader to be able to
boot a file must be placed in /sbin.
Configuration files for boot loaders that are not required at boot
time must be placed in /etc.
3.5.2. Specific Options
The operating system kernel must be located in either
/ or /boot.
Certain architectures may have other requirements for
/boot related to limitations or expectations
specific to that architecture. These requirements are not enumerated
here; distributions are allowed to add requirements as needed to
enable system startup on these architectures.
Lib directory

The /lib is usually reserved for essential system libraries, while additional libraries that are used by applications are typically located in other directories like /usr/lib or /usr/local/lib
It is like Program files in the Windows operating system.
Essential user command binaries (for use by all users)
3.4.1. Purpose
3.4.2. Requirements
There must be no subdirectories in /bin.
If is not the POSIX compatible shell
command itself, it must be a hard or symbolic link to the real shell
command.
Rationale
Various shells behave differently when called as
, so as to preserve POSIX compatibility while
allowing changes or extensions to POSIX when desired.
3.4.3. Specific Options
may be a symbolic link to
or
.
Rationale
The ,
and
commands have been added to make restoration of a
system possible (provided that / is intact).
Conversely, if no restoration from the root partition is ever
expected, then these binaries might be omitted (e.g., a ROM chip root,
mounting /usr through NFS). If restoration of a
system is planned through the network, then
or (along with everything necessary to get
an ftp connection) must be available on the root partition.
Dev directory

This directory represents all the physical and virtual devices that are mounted (connected) to the system.
The device files in /dev are organized into child directories (subdirectories) based on the type of device they represent. For example:
/dev/ttycontains files for serial and parallel ports./dev/netcontains the network interfaces.
/snap
This is where snap packages go into. Snap is a package management system developed by Canonical, the publisher and maintainer of Ubuntu. Snaps are containerized, cross-distribution software packages that are packaged with all their dependencies. They are easy to install and are intended to work across all major Linux distributions that have snap enabled.
If you have installed an application from a snap package, then all the software files will be found in the /snap directory.
/usr – User Binaries

I would like to stop little more on sub-directories of this /usr folder.
/usr/bin contains the programs installed by your Linux distribution. There are usually thousands of programs here.

The libraries for this /usr/bin executables are located in the /usr/lib folder.

The /usr/local doesn’t have any programs by default, but if you compile and install a program system-wide it will be placed here.


Application cache data
5.5.1. Purpose
/var/cache is intended for cached data from
applications. Such data is locally generated as a result of
time-consuming I/O or calculation. The application must be able to
regenerate or restore the data. Unlike
/var/spool, the cached files can be deleted
without data loss. The data must remain valid between invocations of
the application and rebooting the system.
Rationale
5.5.2. Specific Options
5.5.3. /var/cache/fonts : Locally-generated fonts (optional)
5.5.3.1. Purpose
5.5.3.2. Specific Options
Other dynamically created fonts may also be placed in this tree,
under appropriately-named subdirectories of
/var/cache/fonts.
5.5.4. /var/cache/man : Locally-formatted manual pages (optional)
5.5.4.1. Purpose
Preformat all manual pages alongside the unformatted versions.
Allow no caching of formatted man pages, and require formatting to be
done each time a man page is brought up.Allow local caching of formatted man pages in
/var/cache/man.
The structure of /var/cache/man needs to
reflect both the fact of multiple man page hierarchies and the
possibility of multiple language support.
Man pages written to /var/cache/man may
eventually be transferred to the appropriate preformatted directories
in the source man hierarchy or expired; likewise
formatted man pages in the source man hierarchy
may be expired if they are not accessed for a period of time.
Rationale
Directories and files
A directory is a folder that can contain files and other directories. Think of it like a container that holds other containers(directories) and items(files). A file, on the other hand, is a collection of data that can be stored on a computer. it can contain text, images, videos, or any other type of data.
The main difference between files and directory is that the file stores data while the directory can store files and other directories.
Lib32
This directory is similar to /lib but for 32-bit version files. It contains all the files that are installed for software that supports 32-bit applications.
/usr

At a glance, here are some of the salient subdirectories contained in the /usr directory:
/usr/lib— This provided libraries needed by the/usr/binand/usr/sbindirectories./usr/src— This contains the Linux header files, kernel sources, and documentation.
Variable data for /opt
5.12.1. Purpose
Variable data of the packages in /opt must
be installed in /var/opt/<subdir>, where
<subdir> is the name of the subtree in
/opt where the static data from an add-on
software package is stored, except where superseded by another file in
/etc. No structure is imposed on the internal
arrangement of /var/opt/<subdir>.
Rationale
Refer to the rationale for /opt.
Specific Options
/etc
The /etc directory contains host-specific system-wide configuration files. It stores configuration files required by all programs as well as startup and shutdown shell scripts.

Var directory

/var directory is used to store variable data files that are generated and updated during the operation of the system. This directory contains files such as backups, crash logs, metrics, some other log files, and some other temporary variable files as well.
Here «var» stands for «variable», and these containing files are expected to grow over time, such as log files, spool files, and temporary files.
Directory for standard include files.
4.5.1. Purpose
This is where all of the system’s general-use include files for the C
programming language should be placed.
4.5.2. Specific Options
Application spool data
5.14.1. Purpose
5.14.2. Specific Options
5.14.3. /var/spool/lpd : Line-printer daemon print queues (optional)
5.14.3.1. Purpose
The lock file for ,
lpd.lock, must be placed in
/var/spool/lpd. It is suggested that the lock
file for each printer be placed in the spool directory for that
specific printer and named lock.
5.14.3.2. Specific Options
5.14.4. /var/spool/rwho : Rwhod files (optional)
5.14.4.1. Purpose
This directory holds the information
for other systems on the local net.
Rationale
Some BSD releases use /var/rwho for this
data; given its historical location in /var/spool
on other systems and its approximate fit to the definition of
`spooled’ data, this location was deemed more appropriate.
Requirements
Several directories are `reserved’ in the sense that they must
not be used arbitrarily by some new application, since they would
conflict with historical and/or local practice. They are:
/var/backups /var/cron /var/msgs /var/preserve
/dev – Device Nodes
Here, I need to introduce another important concept of Linux – everything is a file. The /dev folder contains files for all devices your Linux is able to recognize.

If you have some Linux experience, you may recall that when you mount a hard drive, you use a name such as /dev/sda1. The sda is the name of a first hard drive recognized by your Linux kernel and it is located in the dev folder. When the disk is mounted, you see it as a folder in that mounting point.
You can also find here USB devices, CPU etc.
Device files
3.6.1. Purpose
The /dev directory is the location of
special or device files.
3.6.2. Specific Options
If it is possible that devices in /dev will
need to be manually created, /dev must contain a
command named MAKEDEV, which can create devices
as needed. It may also contain a MAKEDEV.local
for any local devices.
If required, MAKEDEV must have provisions
for creating any device that may be found on the system, not just
those that a particular distribution installs.
Alternate format essential shared libraries (optional)
3.10.1. Purpose
3.10.2. Requirements
/lost+found – Recovered Files
You will have this directory if you use the ext4 file system. Most of the modern Linux distros use ext4, so most likely you have this folder. This is a file system specific folder that is used for data recovery in case of file corruption. Unless something bad has happened, this folder should be empty on your system.

This /lost+found folder is produced on every separate partition. So, if your /home folder is on a separate partition, you should have this /lost+found folder in your home directory too.
/media – Automatic mount point
This folder is used for automatic mounting of removable media such as USB drives, CD-ROM etc. For example, if your system is configured for automatic mounting, when you insert a USB drive it will be mounted to this folder.

/sys
This is a virtual or pseudo filesystem that contains a collection of virtual files that are attached to the Linux Kernel.

Purpose
/var is specified here in order to make it
possible to mount /usr read-only. Everything
that once went into /usr that is written to
during system operation (as opposed to installation and software
maintenance) must be in /var.
If /var cannot be made a separate
partition, it is often preferable to move /var
out of the root partition and into the /usr
partition. (This is sometimes done to reduce the size of the root
partition or when space runs low in the root partition.) However,
/var must not be linked to
/usr because this makes separation of
/usr and /var more difficult
and is likely to create a naming conflict. Instead, link
/var to /usr/var.
Applications must generally not add directories to the top level
of /var. Such directories should only be added
if they have some system-wide implication, and in consultation with
the FHS mailing list.
Specific Options
An exception is made for the X Window System because of
considerable precedent and widely-accepted practice.
/usr/spool -> /var/spool /usr/tmp -> /var/tmp /usr/spool/locks -> /var/lock
Once a system no longer requires any one of the above symbolic links,
the link may be removed, if desired.
/var
Var stands for variable. As the name suggests the /var directory is a directory that contains files that are constantly changing in size such as log and spool files.

Here is a list of the salient directories contained in the /var directory:
/var/log— Contains system and application log files./var/cache— Contains cached data from programs./var/spool— Comprises queued or spooled files for various programs./var/spool/cron— Contains spooled files for cron jobs./var/spool/at— Contains spooled jobs for at./var/spool/lpd— Contains spooled files for printing./var/opt— Contains variable data files for the/optdirectory.
Run-time variable data
3.15.1. Purpose
This directory contains system information data describing the
system since it was booted. Files under this directory must be
cleared (removed or truncated as appropriate) at the beginning of the
boot process.
The purposes of this directory were once served by
/var/run. In general, programs may continue to
use /var/run to fulfill the requirements set out
for /run for the purposes of backwards
compatibility. Programs which have migrated to use
/run should cease their usage of
/var/run, except as noted in the section on
/var/run.
3.15.2. Requirements
Process identifier (PID) files, which were originally placed in
/etc, must be placed in
/run. The naming convention for PID files is
<program-name>.pid. For example, the
PID file is named
/run/crond.pid.
Programs that read PID files should be somewhat flexible in what
they accept; i.e., they should ignore extra whitespace, leading
zeroes, absence of the trailing newline, or additional lines in the
PID file. Programs that create PID files should use the simple
specification located in the above paragraph.
System programs that maintain transient UNIX-domain sockets must
place them in this directory or an appropriate subdirectory as
outlined above.
/srv – Service Data
This directory contains service files installed on your system. For example, if you installed a web-served on your Linux system, it will be located in this folder.

/var/lock
5.9.1. Purpose
Lock files should be stored within the
/var/lock directory structure.
The format used for the contents of such lock files must be the
HDB UUCP lock file format. The HDB format is to store the process
identifier (PID) as a ten byte ASCII decimal number, with a trailing
newline. For example, if process 1230 holds a lock file, it would
contain the eleven characters: space, space, space, space, space,
space, one, two, three, zero, and newline.
Data for services provided by this system
3.17.1. Purpose
/srv contains site-specific data which is
served by this system.
Rationale
Run directory

/run directory is a temporary filesystem that is created at boot time and is usually stored in the RAM of the System. It is used to store runtime data that is needed by the system and applications during their ongoing operations.
/run/lock: A directory that contains lock files for various processes.
Temporary files preserved between system reboots
5.15.1. Purpose
The /var/tmp directory is made available
for programs that require temporary files or directories that are
preserved between system reboots. Therefore, data stored in
/var/tmp is more persistent than data in
/tmp.
Files and directories located in /var/tmp
must not be deleted when the system is booted. Although data stored
in /var/tmp is typically deleted in a
site-specific manner, it is recommended that deletions occur at a less
frequent interval than /tmp.
/sbin
which reboot
Purpose
The contents of the root filesystem must be adequate to boot,
restore, recover, and/or repair the system.
To boot a system, enough software and data must be present on the root partition
to mount other filesystems. This includes utilities, configuration,
boot loader information, and other essential start-up data.
/usr,/opt, and
/varare designed such that they may be located
on other partitions or filesystems.To enable recovery and/or repair of a system, those utilities
needed by an experienced maintainer to diagnose and reconstruct a
damaged system must be present on the root filesystem.To restore a system, those utilities needed to restore from
system backups (on floppy, tape, etc.) must be present on the root
filesystem.
Rationale
It is occasionally mounted from very small media.
Disk errors that corrupt data on the root filesystem are a
greater problem than errors on any other partition. A small root
filesystem is less prone to corruption as the result of a system
crash.
These considerations must be balanced against the need for a
minimally useful operating environment, for the sake of the boot
process as well as in failure recovery situations.
Applications must never create or require special files or
subdirectories in the root directory. Other locations in the FHS
hierarchy provide more than enough flexibility for any package.
Rationale
There are several reasons why creating a new subdirectory of
the root filesystem is prohibited:
Distributions should not create new directories in the root
hierarchy without extremely careful consideration of the consequences
including for application portability.
Lib64
Similar to /lib32 but for 64-bit version files. It contains all the files that are installed for software that supports 64-bit applications.
For example, if you connect a USB drive to the system, the system will create a new subdirectory under /media, such as /media/usb and mount the file system of the USB drive at that location. However, it depends on different cases.

(Ignore my nickname) You can see my Pen drive in /media/shubh/
Linux Environment Variables
Now that you understand the Linux file system a bit better, it’s also important to know that there are a number of default environment variables that are used by the system.
To view all of the environment variables that are set on your system, run the command printenv
Some common environment variables include:
PATH = A list of directories to be searched when executing commands. When you run a command without specifying a path, the system will search those directories in this order and use the first found executable.
The $PATH Variable
The PATH variable is one of the most important environment variables to know about when managing your own software in the cloud, but what exactly does this variable do?
Well, whenever you need to specify a particular file or directory in a command, you often use an absolute path (i.e. the complete path starting from the root directory e.g. /home/ubuntu/inputs/myfile.txt) or a relative path (i.e. a path starting from the current directory). These paths specify the location of the file or directory so that the command can find it.
To execute a command, we can also call upon software executables. We can tell the system what command to execute in the same way, by providing a path, but this is a lot of typing! For example, imagine having to type/usr/bin/cd every time you wanted to change directories, instead of just cd. The PATH environment variable overcomes this issue by providing a list of directories that contain program executables you may wish to execute.
Note: If you have previously worked with shared computing clusters, you may be used to the
module loadcommand when wanting to use a particular program. This command works by modifying yourPATHand other environment variables (if required) so that your program is ready for you to use.
If you have installed a new program on your machine but you are getting a «command not found» error (or if the which command cannot find your executable), it is likely that your new software is located somewhere outside those directories listed in your current PATH. So, to ensure your new program can be found without always having to specify the path to the program, you can either move or copy the program executable to a directory that is already listed in your path variable, OR add a new directory to your PATH that contains the program.
There are two ways to add a new directory to your PATH. The first is a temporary solution where you simply re-export the PATH variable with the added directory included. For example, if you wanted to add the directory /home/ubuntu/myprogram/bin to the END of your PATH, you would run: export PATH=$PATH:/home/ubuntu/myprogram/bin. Alternatively, to add the directory to the START of your PATH, you would run: export PATH=/home/ubuntu/myprogram/bin:$PATH (see Note about directory order below). This method will only change your PATH in the current session so the changes will not be saved if you open another session. If you want the changes to be made permanently, you will need to add the same export command to your ~/.bashrc file. That way the export command will be run whenever you launch a new session.
Note: The order of directories in your
PATHis important because if the same program (or executable with the same name) is found in two different directories, the one that is found first in your path will be used. So keep this in mind when adding new directories to your path to determine where they should sit in the list of directories in yourPATH. It is also important to know that each user will have their ownPATHvariable, so the root user may not search through the same directories as the standard user.
With your newfound knowledge of the Linux file system, and the highly important PATH variable, you should now feel more confident in managing your compute environment in the cloud. Your Linux machine is no longer a black box of directories with magical commands that appear out of nowhere.
Now go and deal with those pesky «command not found» errors!

/dev
The /dev directory contains special files that are representative of devices attached to the system. These include consoles, hard drives, or any other peripheral devices plugged into the system. A good example of a device file is /dev/sda which represents the first SATA hard drive attached to the Linux system.
The /dev directory is also a storage location for pseudo devices or virtual devices that do not reference any hardware connected to the system. An example is the /dev/null file which discards any data sent to it.

/tmp

Libraries for programming and packages
4.6.1. Purpose
4.6.2. Specific Options
/root

/lib – Libraries
You already know the /bin directory that contains programs, this /lin folder contains libraries required by those programs from the /bin folder.

Run-time variable data
5.13.1. Purpose
This directory was once intended for system information data
describing the system since it was booted. These functions have been
moved to /run; this directory exists to ensure
compatibility with systems and software using an older version of this
specification.
5.13.2. Requirements
In general, the requirements for /run shall
also apply to /var/run. It is valid to implement
/var/run as a symlink to
/run.
The utmp file, which stores information
about who is currently using the system, is located in this
directory.
/sbin – System Binaries

Add-on application software packages
3.13.1. Purpose
/opt is reserved for the installation of
add-on application software packages.
A package to be installed in /opt must
locate its static files in a separate
/opt/<package> or
/opt/<provider> directory
tree, where <package> is a name that
describes the software package and
<provider> is the provider’s LANANA
registered name.
3.13.2. Requirements
No other package files may exist outside the
/opt, /var/opt, and
/etc/opt hierarchies except for those package
files that must reside in specific locations within the filesystem
tree in order to function properly. For example, device lock files
must be placed in /var/lock and devices must be
located in /dev.
Distributions may install and otherwise manage software in
/opt under an appropriately registered
subdirectory.
Rationale
The Intel Binary Compatibility Standard v. 2 (iBCS2) also
provides a similar structure for /opt.
Generally, all data required to support a package on a system
must be present within /opt/<package>,
including files intended to be copied into
/etc/opt/<package> and
/var/opt/<package> as well as reserved
directories in /opt.
The minor restrictions on distributions using
/opt are necessary because conflicts are possible
between distribution-installed and locally-installed software,
especially in the case of fixed pathnames found in some binary
software.
Non-essential standard system binaries
4.10.1. Purpose
4.10.2. Requirements
There must be no subdirectories in /usr/sbin.
Home directory

Note: home directory is denoted by a tilde sign ~
Alternate format libraries (optional)
4.8.1. Purpose
Proc directory

/proc is a directory that contains all the currently running processes. There is one important point to note is that the /proc file system is not a physical file system, but rather a virtual file system that is generated in memory and populated with system information by the kernel.
Linux kernel can send and receive information from here to the terminal.
Understand the Key Terminologies
Before we dive into the world of commands and file systems, let’s make sure we are on the same page by clearing up some key terminologies.
Network Information Service (NIS) database files (optional)
5.16.1. Purpose
Variable data for the Network Information Service (NIS),
formerly known as the Sun Yellow Pages (YP), must be placed in this
directory.
Rationale
Binaries run by other programs (optional)
4.7.1. Purpose
Applications which use /usr/libexec in this
way must not also use /usr/lib to store internal
binaries, though they may use /usr/lib for the
other purposes documented here.
Rationale
/mnt
The /mnt directory provides a temporary mount point on which removable media such as CDROMs can be mounted. It is most often used to mount storage devices or partitions manually, and is more of a relic of the past.

The difference
1. Different directory levels:
/:The root directory, all directories, files, and devices are under /. / is the organizer of the Linux file system and is the top-level directory.
2. The time of catalog generation is different:
3. Different file permissions:
/etc – Configuration Files
The /etc folder comprises all system-wide configuration files and some shell scripts that are executed during the system boot. All files here are text files, so they are human readable.

If you ever did any system-wide configuration, you probably edited some files here.
For example, there is /etc/fstab file that contains a table of storage devices and their mounting points.
Chapter 6. Operating System Specific Annex
This section is for additional requirements and recommendations
that only apply to a specific operating system. The material in this
section should never conflict with the base standard.
/boot – Boot Files
It is easy to guess from the name. This folder is needed to boot your system. It contains the Linux kernel, initial RAM disk image for drives need at boot time, and the bootloader.

I also would like to point out that within this boot folder, you can find the grub folder that contains grub configuration files.
If you read my Arch Linux post, you should remember than I used this command to generate the GRUB configuration file.
sudo grub-mkconfig -o /boot/grub/grub.cfgThe boot folder also contains the Linux kernel.
Linux Root folders
I won’t use the terminal here and I will show you some visual presentation. But you are of course are encouraged to open the terminal and explore all these directories. Let’s get started.
Linux
This is the annex for the Linux operating system.
6.1.1. / : Root directory
On Linux systems, if the kernel is located in
/, we recommend using the names
vmlinux or vmlinuz, which
have been used in recent Linux kernel source packages.
6.1.2. /bin : Essential user command binaries (for use by all users)
Linux systems which require them place these additional files into
/bin:
6.1.3. /dev : Devices and special files
All data written to this device is discarded. A read from this device
will return an EOF condition.This device is a source of zeroed out data. All data written to this
device is discarded. A read from this device will return as many bytes
containing the value zero as was requested.This device is a synonym for the controlling terminal of a
process. Once this device is opened, all reads and writes will behave
as if the actual controlling terminal device had been opened.
Rationale
Previous versions of the FHS had stricter requirements for
/dev.
Other devices may also exist in /dev.
Device names may exist as symbolic links to other device nodes
located in /dev
or subdirectories of /dev.
There is no requirement
concerning major/minor number values.
6.1.4. /etc : Host-specific system configuration
Linux systems which require them place these additional files into
/etc.
6.1.5. /proc : Kernel and process information virtual filesystem
The proc filesystem
is the de-facto
standard Linux method for handling process and system information,
rather than /dev/kmem
and other similar methods.
We strongly encourage this for the storage and retrieval of process
information as well as other kernel and memory information.
6.1.6. /sbin : Essential system binaries
Linux systems place commands relating to filesystem maintenance and
boot loader management into /sbin.
Optional files for /sbin:
Static () and
static () are
useful when things go wrong. The primary use of
(to repair incorrect symlinks in
/libafter a poorly orchestrated upgrade) is no
longer a major concern now that the
program (usually located in/usr/sbin)
exists and
can act as a guiding hand in upgrading the dynamic libraries. Static
is useful in some emergency situations.
Note that these need not be statically linked versions of the standard
and , but may
be.I’ve just removed
/lib/<file>.I have a static , but I don’t know what to call the link.
So as to cope with the fact that some keyboards come up with
such a high repeat rate as to be unusable,
may be installed in
/sbinon some systems.Since the default action in the kernel for the Ctrl-Alt-Del key
combination is an instant hard reboot, it is generally advisable to
disable the behavior before mounting the root filesystem in read-write
mode. Some suites are able to disable
Ctrl-Alt-Del, but others may require the
program, which may be installed in
/sbinon those systems.
6.1.7. /sys : Kernel and system information virtual filesystem
The sys filesystem
is the location where
information about devices, drivers, and some kernel features is
exposed. Its underlying structure is determined by the particular
Linux kernel being used at the moment, and is otherwise
unspecified.
6.1.8. /usr/include : Header files included by C programs
These symbolic links are required if a C or C++ compiler is
installed and only for systems not based on glibc.
/usr/include/asm -> /usr/src/linux/include/asm-<arch> /usr/include/linux -> /usr/src/linux/include/linux
6.1.9. /usr/src : Source code
The only source code that should be placed in a specific
location is the Linux kernel source code. It is located in
/usr/src/linux.
If a C or C++ compiler is installed, but the complete Linux
kernel source code is not installed, then the include files from the
kernel source code must be located in these directories:
/usr/src/linux/include/asm-<arch> /usr/src/linux/include/linux
<arch> is the name of the system
architecture.
Note
/usr/src/linux
may be a symbolic link to a kernel source code tree.
Rationale
6.1.10. /var/spool/cron : cron and at jobs
This directory contains the variable data for the
and programs.
/root – Root Home

If you log in as a root, you will be located in this directory by default. This is a folder for private data and account specific setting of your root account.
Boot directory

As its name suggests, this directory contains files that are required by the operating system to boot properly.
When the computer starts up, the BIOS or UEFI firmware initializes the hardware and looks for a bootable device. If the boot device is a hard drive, the firmware loads the bootloader from the first sector of the disk and executes it. The GRUB (Grand Unified Bootloader) on Linux systems, which loads the Linux kernel is usually located in the /boot directory. (GRUB + Boot files)
/home – Users’ Folder

Log files and directories
5.10.1. Purpose
This directory contains miscellaneous log files. Most logs must
be written to this directory or an appropriate subdirectory.
5.10.2. Specific Options
Process accounting logs (optional)
5.4.1. Purpose
This directory holds the current active process accounting log
and the composite process usage data (as used in some UNIX-like
systems by and
).
/run – Early temp
The /run is a recently introduced folder that is actually a temporary file-system. It is used to store temporary files very early in system boot before the other temporary folders become available.

/run
Most Linux distributions come with the /run filesystem. This is a directory that stores volatile runtime data since the system was started. Data stored in this directory does not persist upon a reboot.

Scope
This document specifies a standard filesystem hierarchy for FHS
filesystems by specifying the location of files and directories, and
the contents of some system files.
The FHS grew out of earlier work on FSSTND, a filesystem
organization standard for the Linux operating system. It builds on
FSSTND to address interoperability issues not just in the Linux
community but in a wider arena including 4.4BSD-based operating
systems. It incorporates lessons learned in the BSD world and
elsewhere about multi-architecture support and the demands of
heterogeneous networking.
Although this standard is more comprehensive than previous
attempts at filesystem hierarchy standardization, periodic updates may
become necessary as requirements change in relation to emerging
technology. It is also possible that better solutions to the problems
addressed here will be discovered so that our solutions will no longer
be the best possible solutions. Supplementary drafts may be released
in addition to periodic updates to this document. However, a specific
goal is backwards compatibility from one release of this document to
the next.
Comments related to this standard are welcome. Any comments or
suggestions for changes may be directed to the
FHS mailing list, or filed as bugs, or both.
Typographical or grammatical comments should be filed as bugs.
The bugtracker is at
http://bugs.linuxfoundation.org
— use the category FHS.
Before sending mail to the mailing list it is requested that you
first glance at the mailing list archives to avoid excessive re-discussion
of old topics.
Questions about how to interpret items in this document may
occasionally arise. If you have need for a clarification, please
contact the FHS mailing list. Since this standard represents a
consensus of many participants, it is important to make certain that
any interpretation also represents their collective opinion. For this
reason it may not be possible to provide an immediate response unless
the inquiry has been the subject of previous discussion.
/opt – Optional Software
This folder is not essential for your system to work. Usually, it is used to install commercial programs on your system. For example, my Dropbox installation is located in this folder.

Conventions
We recommend that you read a typeset version of this document rather
than the plain text version. In the typeset version, the names of files
and directories are displayed in a constant-width font.
Components of filenames that vary are represented by a description
of the contents enclosed in «<» and
«>» characters,
<thus>. Electronic mail addresses are also
enclosed in «<» and «>» but are shown in the usual
typeface.
Variable substrings of directory names and filenames are indicated
by «*«.
The sections of the text marked as
are explanatory and are
non-normative.
/home

In addition, home directories contain personalized configuration files which are hidden files preceded by a dot. Such files include the .bashrc, .bash_logout, and .bash_profile to mention a few.
To view hidden files, run the ls command with the -la option as shown.
ls -la
Swapfile (not a directory)
/swapfile is used as a swap space for virtual memory management.
Virtual memory is a technique used by operating systems to create some extra virtual space in case your RAM gets completely used.
When the physical memory (RAM) of a system is full, the operating system moves some of the less-used data from RAM to the swap space on the disk.
The /swapfile is typically created during the installation of a Linux system or can be created manually.
The size of the /swapfile can be adjusted depending on the needs of the system. It can also be disabled or deleted if not needed, although having some swap space is usually recommended.
Home directory for the root user (optional)
3.14.1. Purpose
/var – Variable Files
The /var contains files that are of variable content, so their content is not static and it constantly changes. For example, this is where the log files are stored. If you don’t know, a log file is a file that records all events happening in your system while it is running. These log files often help to find out if something is not working correctly in your system.

Dedication
This release is dedicated to the memory of Christopher Yeoh,
a long-time friend and colleague, and one of the original editors
of the FHS. Without his dedication this work would not have been possible.
Tmp directory

/tmp contains all the temporary files that are needed only for a short period of time.
These files may include log files, cache files, and other types of temporary data.
Chapter 5. The /var Hierarchy
Chapter 2. The Filesystem
This standard assumes that the operating system underlying an
FHS-compliant file system supports the same basic security features
found in most UNIX filesystems.
Rationale
Static and variable files should be segregated because static
files, unlike variable files, can be stored on read-only media and
do not need to be backed up on the same schedule as variable
files.
Historical UNIX-like filesystem hierarchies contained both
static and variable files under both /usr and
/etc. In order to realize the advantages
mentioned above, the /var hierarchy was
created and all variable files were transferred from
/usr to /var.
Consequently /usr can now be mounted read-only
(if it is a separate filesystem). Variable files have been
transferred from /etc to
/var over a longer period as technology has
permitted.
Here is an example of a FHS-compliant system.
(Other FHS-compliant layouts are possible.)
General Guidelines
Here are some of the guidelines that have been used in the development
of this standard:
Solve technical problems while limiting transitional difficulties.
Make the specification reasonably stable.
Gain the approval of distributors, developers, and other decision-makers
in relevant development groups and encourage their participation.Provide a standard that is attractive to the implementors of different
UNIX-like systems.
Specific Options
Each directory listed above is specified in detail in separate
subsections below.
Chapter 3. The Root Filesystem
2, the root directory refers to the top directory, which is «/»
There are many directories under the root directory, such as:
dev home lib64 mnt opt root sbin sys usr
boot etc lib media newFS proc run srv tmp varSnap directory

/snap directory is used by the Snap package management system. Snap packages are self-contained software packages that contain all of the dependencies and libraries needed to run the software. /snap directory is where Snap packages are installed on the system. When a Snap package is installed, its files are placed in a directory under /snap with each package having its own unique directory.

As you can see in above image, I have installed ksnip software to take screenshots of my screen, this software has its own snap sub-directory /snap/ksnip/ that contains all of its dependencies and files. The snapd daemon manages the installation, configuration, and updation of the packages.
For example: if I want to install software which is available on the snap store then I would have to use sudo snap install package-name command to install that snap package.
/bin – Binaries
The /bin folder contains programs that are essential for the system to boot and run. So, if you destroy this folder, your system won’t boot and run.

These programs are stored in the binary format. In other words, they are not in text format. You cannot open and read the content of these programs. The advantage of such format is that a computer can read and execute these programs very fast.
/mnt – Manual mount point
The /mnt folder is similar to the /media folder, it is also used to mount devices, but usually, it is used for manual mounting. You, of course, can manually mount your devices to /media, but to keep some order in your system it is better to separate these two mounting points.

Most user commands
4.4.1. Purpose
This is the primary directory of executable commands on the
system.
4.4.2. Requirements
There must be no subdirectories in /usr/bin.
4.4.3. Specific Options
Rationale
In many executable scripts, the interpreter to be invoked to
execute the script is specified using
#!path_to_interpreter
on the first line of a script.
To make such scripts portable among different systems,
it is advantageous to standardize the interpreter locations.
The shell interpreter is already
fixed in /bin by this specification,
but interpreters for Perl, Python, Tcl and expect may be installed
in various places. The locations specified here may be implemented
as symbolic links to the physical location of the interpreters.
System crash dumps (optional)
5.6.1. Purpose
This directory holds system crash dumps. As of the date of this
release of the standard, system crash dumps were not supported under
Linux but may be supported by other systems which may comply with the
FHS.
1, the home directory is the user’s / home directory, which is divided into two cases
(1), ordinary users
/home/linuxprobe (linuxprobe is the set username, you can also set it yourself)(2), root user
/root/ ( Root Directory)
Denoted by a single forward slash ( / ), the root directory is the topmost directory in the Linux hierarchy structure, as discussed earlier. All files and folders on your Linux system are stored here and can be referenced from this directory, even when stored in various locations such as removable or virtual devices.

The root (/) directory is not to be confused with the root home directory ( /root ).
Essential shared libraries and kernel modules
3.9.1. Purpose
3.9.2. Requirements
3.9.3. Specific Options
/media
The /media directory contains temporary sub-directories on which removable media such as optical drives are automatically mounted. A good example of a sub-directory is /media/cdrom for optical drives.
Etc directory

/bin

To confirm the path of a binary executable or command such as the cp command, run the command:
which cp
Temporary files
3.18.1. Purpose
The /tmp directory must be made available
for programs that require temporary files.
Programs must not assume that any files or directories in
/tmp are preserved between invocations of the
program.
Rationale
IEEE standard POSIX.1-2008 lists requirements
similar to the above section.
Although data stored in /tmp may be deleted
in a site-specific manner, it is recommended that files and
directories located in /tmp be deleted whenever
the system is booted.
Requirements
Each directory listed above is specified in detail in separate
subsections below. /usr and
/var each has a complete section in this
document due to the complexity of those directories.
/proc
Also referred to as the proc filesystem, The /proc directory is a virtual or pseudo filesystem that contains special files that provide information about running processes and the kernel’s current state. It is regarded as the information and control center of the Linux kernel.
The proc directory is a peculiar directory in that it’s not a real filesystem and it ceases to exist once the system is powered off. It is mounted at the /proc mount point during the booting process.

3, how to switch between ordinary users and root users
(1), ordinary user → root user
Su Enter the password directly Su root Enter your password(2), root user → ordinary user
(1), su linuxprobe (linuxprobe is the username) (2), Ctrl+D direct switch/boot
Another critical directory is the /boot directory. The directory, as the name implies, contains essential files needed to successfully boot the system. These files include the grub bootloader files, root filesystem files, Linux kernel files (vmlinuz), and other boot configuration files.

Mount point for removable media
3.11.1. Purpose
This directory contains subdirectories which are used as mount
points for removable media such as floppy disks, cdroms and zip
disks.
Rationale
Historically there have been a number of other different places
used to mount removable media such as /cdrom,
/mnt or /mnt/cdrom. Placing
the mount points for all removable media directly in the root
directory would potentially result in a large number of extra
directories in /. Although the use of
subdirectories in /mnt as a mount point has
recently been common, it conflicts with a much older tradition of
using /mnt directly as a temporary mount point.
3.11.2. Specific Options
Contributors
Opt directory
/opt is a directory that is used for installing optional or add-on software packages that are not provided by the distribution’s package manager. Here «opt» stands for «optional».

In the above image, you can see that Brave browser required some additional files to be installed which are kept in /opt/brave.com/brave
/ directory
In Linux, the / or root directory is the highest-level directory in the file system hierarchy. It is denoted by a forward slash /. It is the starting point for all file paths on the system and contains all other directories and files on the system. This is where everything starts from.

In the above image, I used the cd command to change my current directory to / directory and then I used ls command to show the list of directories that are inside the root.
You can see all the child directories inside the / root directory. Let’s start with the /bin
Variable game data (optional)
5.7.1. Purpose
Rationale
/var/games has been given a hierarchy of
its own, rather than leaving it underneath
/var/lib as in release 1.2 of this standard.
The separation
allows local control of backup strategies, permissions, and disk
usage, as well as allowing inter-host sharing and reducing clutter in
/var/lib. Additionally,
/var/games is the path traditionally used by BSD.
Source code (optional)
4.12.1. Purpose
Mount point for a temporarily mounted filesystem
3.12.1. Purpose
This directory must not be used by installation programs: a
suitable temporary directory not in use by the system must be used
instead.
Operating system
Linux Vs Unix
Note: «Open source» means that the source code of a software or operating system is freely available for anyone to view, modify, and distribute. «Proprietary» operating system is a software that is owned by a company and its source code is not available to the public.
Ubuntu:
Ubuntu is a popular distribution of Linux. Let’s back to our car analogy, Linux is the car brand and Ubuntu is the car model. Just like a car model within a brand has its own features and characteristics that make it unique from other models within that brand. Ubuntu has unique features that differentiate it from other Linux distributions. Linux has other distributions such as Fedora, Debian, and Red Hat, each with its own unique set of features, software, and configurations.
/lib,/lib64

/srv (Service directory)
The term srv stands for service. The/srvdirectory contains site-specific data for your Linux distribution. It points to the location for data files for a specific service such as www, rsync, FTP and CVS.
Purpose
Large software packages must not use a direct subdirectory under
the /usr hierarchy.






