INFO | Overview of Linux Directories

INFO | Overview of Linux Directories

Updated Author Andreas Hepp ⏱ 3 min read
Inhaltsverzeichnis

Anyone analyzing or repairing a Linux system needs to know where configurations, logs, and data are stored. The Filesystem Hierarchy Standard (FHS 3.0, released in 2015) defines this structure for Linux. Distributions largely adhere to it, with minor deviations in details.

The table lists the common directories, followed by special cases where old descriptions are no longer accurate.

Directories at a Glance

System, hardware and runtime

DirectoryDescriptionDetails and Files
/bootFiles for the boot processKernel, bootloader, and their configurations
/devDevice filesVirtual files for devices such as /dev/null, /dev/sda
/etcSystem-wide configuration filesfstab, hosts, hostname, resolv.conf, timezone (Debian and Ubuntu)
/procVirtual filesystemInformation about processes and system state
/sysVirtual filesystemInformation about hardware and kernel
/runRuntime data since bootPID files and sockets, resides in RAM (tmpfs)
/run/lockLock filesPrevents concurrent access to resources
/lost+foundFilesystem recovery directoryThis is where the filesystem check stores file fragments, with a separate directory for each filesystem

Programs and libraries

DirectoryDescriptionDetails and Files
/binEssential user command binariesbash, chmod, cp, ls, mv, ping, touch (often symlinked to /usr/bin)
/sbinSystem binariesfdisk, reboot, route, mkfs (often symlinked to /usr/sbin)
/libShared libraries and kernel modulesFor binaries in /bin and /sbin (often symlinked to /usr/lib)
/lib3232-bit libraries on 64-bit systemsFor 32-bit applications
/lib6464-bit librariesFor 64-bit applications
/usrUser programs and data/usr/bin (programs), /usr/lib (libraries)
/usr/localLocally installed softwareSelf-compiled or manually installed programs
/optOptional additional softwarePrograms and data, often from third parties
/snapSnap packagesMounted Snap applications (Ubuntu)

User data, services, and mount points

DirectoryDescriptionDetails and Files
/homeUser directoriesPersonal data and configuration for each user
/rootHome directory of the root userLocated outside of /home so that root can operate even if /home is not mounted
/varVariable dataLogs, caches, spool directories, email queues
/tmpTemporary filesFor short-lived data
/srvData for servicesFiles served by web or FTP servers
/mediaMount points for removable mediaUSB drives, CDs that are automatically mounted
/mntTemporary mount pointsFor file systems that you mount manually

Additional important paths

PathDescription
/etc/skelTemplate for new user directories
/var/logSystem and application logs, first point of call for troubleshooting
/var/spoolSpool files for tasks such as printing and email
/proc/cpuinfo and /proc/meminfoInformation about CPU and RAM
/dev/shmShared memory for applications

Edge cases: When old descriptions are no longer accurate

Merged /usr. On distributions with a merged /usr, such as Fedora, /bin, /sbin, /lib, and /lib64 are symlinks to their counterparts in /usr. The programs are then physically located only in /usr, and both paths access the same file. The separation dates back to a time when /usr was on a separate disk and is now obsolete. Check on your system with ls -ld /bin to see if it is a symlink.

/selinux. This directory is obsolete. It was previously the mount point for the selinuxfs filesystem and did not contain any security policies. Since Debian Wheezy, selinuxfs is mounted under /sys/fs/selinux. SELinux policies and configuration are located under /etc/selinux.

/run/shm. Debian introduced /run to consolidate volatile data such as /var/run, /var/lock, and /dev/shm. This resulted in /run/shm. Modern systems use /dev/shm as shared memory, while /run/shm sometimes appears only as a compatibility symlink.

/etc/timezone. This file exists on Debian and Ubuntu. On other distributions, the timezone is stored in /etc/localtime.

More PhinIT articles:

Sources

SourceTopicURL
Filesystem Hierarchy Standard 3.0Structure and Directory Purposeshttps://debian.org/doc/packaging-manuals/fhs/fhs-3.0.html
systemd: Plädoyer für die /usr-Zusammenführung/bin, /sbin, /lib, /lib64 as Symlinks to /usrhttps://systemd.io/THE_CASE_FOR_THE_USR_MERGE/
Fedora Wiki: UsrMoveMerged /usr in Fedora, /run as tmpfshttps://fedoraproject.org/wiki/Features/UsrMove
Debian Wiki: Run DirectoryIntroduction of /run, migration from /dev/shmhttps://wiki.debian.org/ReleaseGoals/RunDirectory
Debian-devel mailing list (2013)Removal of /selinux, selinuxfs under /sys/fs/selinuxhttps://lists.debian.org/debian-devel/2013/05/msg00253.html