Root Directory Structure Of Linux File System The root directory is the top-level directory of the filesystem Root Directory The root directory(/) is the first directory in the filesystem hierarchy. Root of FS is analogous to the trunk of a tree, as the starting point where all branches originate from. All the files in a file system have the root as the starting point in their path. But what is a filesystem? A file system is a process that manages how and where data on a storage disk, typically a hard disk drive (HDD) or a Solid State Drive (SSD), is stored, accessed, and managed. It is a logical disk component that handles the disk's internal operations and presents the human user with an abstraction of the disk. Image Credit: The Linux Foundation File System Hierarchy Standard The Filesystem Hierarchy Standard (FHS) is a reference describing the conventions used for the layout of a UNIX system. It is maintained by the Linux Foundation ( nonprofit consortium dedicated to fostering the growth of Linux ) . It has been made popular by its use in Linux distributions, but it is used by other UNIX variants as well. Listing Files in / ls is a command to list computer files in Unix and Unix-like operating systems. / in “ls /” is the root. So we are listing the files which are in the root directory. Let’s start with /home and /root directories. Why are we covering home and root directions simultaneously? The /root is the home directory meant for just the root user and /home contains directories that are for all the remaining users. /root is the home of the root user. Let’s say we have two users, bob and alice. Their home directories would be (respectively): /home/bob /home/alice Why do the users need “/home” directory? It contains directories that are kind of personal place(Working space) for all the users other than root. There will be a separate folder for each user in /home directory. For example if you have a user called sam, then their default home directory can be /home/sam Only user who owns this sub folder can access its content other than root user. So, user ken can not access user barbi’s home directory content which is located at /home/barbi unless ken has root privileges. Terminal properties, command history file, application setting files(~/.vimrc, ~/.ssh) is located in the home directory of user. System admins when trying to implement a quota for users they will implement it on the user home directories inside the /home directory. /bin directory Bin is abbreviation of binary which means an executable file. This directory contains executables which can be executed to accomplish a task. This folder contains base executables which are required for minimal system working. This folder contains basic commands such as cat, chmod, chgrp, chown, date, dir, dd, df, ln, mv, echo and zipping tools such as bzip, gzip etc. On debian and some other distributions the /bin directory is a symbolic link to /usr/bin /sbin directory This directory contains system binaries or superuser binaries, which are required for changing system properties or system level settings such as disk management, network management etc. This folder can be accessed by normal users but they can not execute any of the commands located in this and whatever commands/scripts located in this folder are executed exclusively by the root user. On debian and some other distributions the /sbin directory is a symbolic link to /usr/sbin The bin, sbin, lib, lib32, libx32 and lib64 are symbolic links to /usr/bin, /usr/sbin, /usr/lib, /usr/lib32, /usr/libx32, /usr/lib64. A symbolic link creates a file in your directory and acts as a shortcut to a file or folder. A symbolic link is a file-system object that points to another file system object. The object being pointed to is called the target. Symbolic links are transparent to users; the links appear as normal files or directories, and can be acted upon by the user or application as if they were normal files. /usr directory usr is an abbreviation of "unix system resources". It contains read-only user data; the majority of (multi-)user utilities and applications. Its contents are shareable and read-only. originally /bin was only for binaries and libraries required for booting, while /usr/bin was for all the other executables and libraries. But now on many distributions such as debian and its derivatives such as Ubuntu /bin is a symbolic link to /usr/bin. Similarly for the for /sbin directory, it is a symbolic link to /usr/sbin. /proc directory proc is abbreviation of processes. The /proc filesystem contains a illusionary filesystem. It does not exist on a disk. Instead, the kernel creates it in memory. The proc filesystem (procfs) is a special filesystem in Unix-like operating systems that presents information about processes and other system information in a hierarchical file-like structure, providing a more convenient and standardized method for dynamically accessing process data held in the kernel The virtual files in /proc have unique qualities. Most of them are 0 bytes in size. Yet when the file is viewed, it can contain quite a bit of information. /boot directory The /boot directory holds files used to boot the OS. The contents are mostly Linux kernel files or boot loader files. vmlinux – the Linux kernel (vmlinuz if compressed) initrd.img – a temporary file system, used prior to loading the kernel GRUB stores its files at /boot/grub/. These files are mostly modules (.mod), with configuration stored in grub.cfg. Contents of /boot and /boot/grub directories. Notice the vmlinuz, initrd.img, grub/, and grub/grub.cfg files. These files were described in the previous slide. /etc directory The /etc (et-see) directory is where a Linux system's configuration files live. A "configuration file" is a file that is used to control the operation of a program. It is a good idea to backup this directory regularly. It will definitely help re-configuration if while upgrading/reinstalling the OS. Normally, no binaries should be or are located here. List of files in /etc directory of an Android device. Android is a Linux device. Swapfile A swap file is a system file that creates temporary storage space on a solid-state drive or hard disk when the system runs low on memory. The file swaps a section of RAM storage from an idle program and frees up memory for other programs. It’s actually a file and not a directory although the directories are files in linux. /dev directory Device files (e.g., /dev/null, /dev/video0, /dev/sda1, /dev/tty, /dev/random). A device file or special file is an interface to a device driver that appears in a file system as if it were an ordinary file. /dev/null – accepts and discards all input written to it; provides an end-of-file indication when read from. /dev/zero – accepts and discards all input written to it; produces a continuous stream of null characters (zero-value bytes) as output when read from. /dev/full – produces a continuous stream of null characters (zero-value bytes) as output when read from, and generates an ENOSPC ("disk full") error when attempting to write to it. /dev/random – produces bytes generated by the kernel's cryptographically secure pseudorandom number generator. Its exact behavior varies by implementation, and sometimes variants such as /dev/urandom and /dev/arandom are also provided. What is mounting? Mounting is a process by which a computer's operating system makes files and directories on a storage device available for users to access via the computer's file system. In general, the process of mounting comprises the operating system acquiring access to the storage medium; recognizing, reading, and processing file system structure and metadata on it before registering them to the virtual file system (VFS) (an abstract layer on top of a more concrete file system, VFS allows client applications to access different types of concrete file systems in a uniform way.) component. The location in the VFS to which the newly mounted medium was registered is called a mount point; when the mounting process is completed, the user can access files and directories on the medium from there. Mounting your pendrive/thumbdrive, mounting external SSD/HDD, mounting your phone’s storage while data transferring. /mnt directory /mnt is for temporary mounting. In other words, where user can mount things. This directory is generally used for mounting filesystems temporarily when needed.