All files on a Linux system are stored on file systems which are organized into a single inverted tree of directories, known as a file system hierarchy. This tree is inverted because the root of the tree is said to be at the top of the hierarchy, and the branches of directories and subdirectories stretch below the root.
The directory / is the root directory at the top of the file system hierarchy. The / character is also used as a directory separator in file names. For example, if etc is a subdirectory of the / directory, we could call that directory /etc. Likewise, if the /etc directory contained a file named issue. We could refer to that file as /etc/issue.
Subdirectories of / are used for the standardized purpose to organize files by type and purpose. This makes it easier to find files. For example, in the root directory, the subdirectory /boot is used for storing files needed to boot the system.
Important Linux Directories:
/usr: Installed software, share libraries, include files, and static read-only program data. Important subdirectories include:
/usr/bin: User commands.
/usr/sbin: System administration commands, Essential system binaries, e.g., fsck, init, route. Example: iptables, reboot, fdisk, ifconfig, swapon
/usr/local: Locally customize the software.
/etc: Configuration files specific to this system.
This also contains startup and shutdown shell scripts used to start/stop individual programs.
/var: Variable data are specific to this system that should persist between boots. Files that dynamically change (e.g. databases, cache directories, log files, printer spooled document, and website content) may be found under /var
/run: Runtime data for processes started since the last boot. This includes process ID files and lock files, among other things. The contents of this directory are recreated on reboot. (This directory consolidates /var/run and /var/lock from the older versions of RHEL.)
/home: Home directory where regular users store their personal data and configuration files.
/root: Primary hierarchy root and root directory of the entire file system hierarchy.
The home directory for the administrative superuser, root.
/tmp: A world-writable space for temporary files. Files that have not been accessed, changed, or modified for 10 days are deleted from this directory automatically. Another temporary directory exists, /var/tmp, in which files that have not been accessed, changed or modified in more than 30 days are deleted automatically.
/boot: Files needed in order to start the boot process.
Kernel initrd, vmlinux, grub files are located under /boot
Example: initrd.img-2.6.32-24-generic, vmlinuz-2.6.32-24-generic
/dev: It contains special device files that are used by the system to access hardware. These include terminal devices, USB, or any device attached to the system. Example: /dev/tty1, /dev/usbmon0
/bin: This is a subdirectory containing your binaries. It contains all shell-based commands like grep ls kill echo gzip vi etc. It is mostly used by the root level user
/etc: Whenever you have to do the configuration. All configs can be located in this folder.
/lib: This is the sole place for Linux libraries. These are shared among all users. No duplication is allowed here.
/opt: This is for package manager for optional packages
/Sbin: All binaries from this place belongs to root user
/var: Any variable data created by the user goes here.
Types of the file system:
EXT: This is the oldest one made for core Linux but it doesn’t use anymore.
EXT2: This system allows you to add 2tb of data on disk.
EXT3: Upgraded version of ex2 with backward compatibility and upgraded features.
These systems have recovery issues. But this is what vanilla Linux supports
EXT4: This is the fastest format and allows large storage. SSD supports are added to this. When you install any OS today by default you will get this system in place.
JFS: IBM made a system that failed a long time ago due to its corrupt system nature.
XFS: This is also one of the oldest systems also small file support makes it sluggish.
BTRFS: It’s used by Oracle only. Its made for database purposes and has good speed.