Linux file system structure
/ – The Root DirectoryEverything on Linux system is located under the / or root directory. The meaning of / or root and root user are often confusing to new Linux users. In Linux, the root directory “/” (The tree of the file system starts at the trunk or slash, indicated by a forward slash /) is a separator between a file and a directory contains all underlying directories and files, yet root user is a super user or administrator user with has administrative privileges on the system vs Linux privileged users who only have limited privileges to protect system security.
/bin – Essential command binariesThe /bin directory is a place contains most commonly essential executable terminal binaries programs or file required during booting, repairing like cat, ls, mount, rm, du, df, tar, rpm, wc, etc.
/boot – Boot loader filesAll of the required files to boot the system contains in /boot directory, including GRUB boot loader’s files, Linux kernels, the Linux initial RAM disk (initrd),
/dev – Device FilesAll of the hardware devices on the machine like cdrom, cpu, hard drives, etc will be stored as special device files that represent all the devices in /dev directory. Device files are created during your Linux system installation.
/etc – Configuration FilesContain host-specific files and directories, e.g. information about system and application configuration files like startup, shutdown, start, stop script for every individual program. In another word /etc data is very similar to Control panel in Microsoft Windows.
/home – Home DirectoryHome directory of the users. Every time you create a new user, a new directory with user’s name is created in /home directory for users to store their own files within their own home’s directory. Most common automatic directories created within /home ‘s user are Desktop, Downloads, Documents, Music, Movie, etc. Most programs configuration file for a specific user will be saved in it’s users /home directory like web browser settings, web browser bookmarks, desktop wallpaper, themes, and passwords.
/lib – Essential LibrariesSimilar to Windows ‘dll’ files, all Linux shared libraries and kernel modules files stores in /lib directory. These important Linux dynamic libraries are required to boot the system and run commands in the root file system.
/lost+found – Recovering FilesSounds weird but yes we have lost+found in Linux file system structure. Every Linux file system and partitions has a lost+found in it’s directory. In the even your system is crashed or unexpected shutdown, you can run fsck command to check and repair the filesystem, fsck will turn any corrupted or almost-deleted files back into files that you can recover them later in /lost+found directory.
/media – Removable Media DevicesEvery time you insert a removable device such as external hard drive, floppy disk, zip drive, CDs, DVDs, flash drive to a Linux system, a new directory will automatically be created inside the /media directory. /media directory is a temporary mount directory for removable devices.
/mnt – Temporarily mounted filesystemsWhile /media is where the system automatically mounts removable media, /mnt is for you to mount things (partitions, file systems, devices) manually and temporarily.
/opt – Optional software packagesThe /opt directory is reserved to store addition software or extra and third-party software for your system, those addition software usually don’t follow the standard file system hierarchy and not handled by the package manager.
/proc – Kernel & Process InformationSimilar to /dev, /proc directory contains information about running process, system resources and information. You can view information about any running process with a specific process-id (pid) or hardware’s information such as memory, cpu, io, etc…
/root – Root Home DirectoryDon’t be confused with “/” or root directory, /root is a root account’s home directory determined by developer or local preference rather than /home/root to allow for booting the system even if /home/ is not available.
/sbin – System binariesSimilar to /bin, /sbin contains essential binaries that are generally intended to be run by the root user for system administration and maintenance purpose. For example: iptables, reboot, fdisk, ifconfig, swapon, init, ip, mount
/selinux – Security-Enhanced LinuxSelinux comes with RedHat based distro (fedora, centos), selinux is a security architecture integrated into the 2.6.x kernel using the Linux Security Modules (LSM). For some reason Centos 6 created an emtpry selinux directory in root directory, the real selinux directory with its configuration files are stored in /etc/selinux/ directory.
/srv – Service DataServer (srv) contains data of services such as HTTP, FTP, rsync, cvs
/sys – virtual filesystemSome newer Linux distros have /sys directory with sysfs virtual filesystem to store information and statistics about (physical and virtual) device and device names. /sys is newly added since Linux kernel 2.6 /sys contains similar information with /proc which display device information about the kernel’s view of the system.
/tmp – Temporary filesSystem’s Temporary Directory, all users and programs in your system can access/read/write in this directory. You should not save/store any important files/directories under /tmp since all files will be removed after system is rebooted.
/usr – binaries, documentation, source code, librariesPronounced as ‘user’, /usr contains the majority of user utilities, programs, libraries, documentation etc for all user-related second level programs rather than applications and files used by the system.
/var – Variable FilesVariable or /var contains data that is expected to change and grow as the system is running (log, mail, spool, temp)