Linux FileSystemHierarchyStandard

Overview

Trying out Ubuntu and other Linux distributions, I have been struggling on the file system hierarchy. Time to refresh my memories with some researches.

FHS : Filesystem Hierarchy Standard

This is a standardization attempt on the file system layout.

FolderDescription
/Root of the file system tree.
/binBinaries : contains foundamental commands and basic tools.
/bootBoot : contains files required to start the system. Should not be modified.
/devDevices : virtual directory that contains all files related to devices. Those files are generated during the installation or at runtime for plug and play devices (USB, …)
/etcEt cetera : Dumping location, system-wide configuration files or system databases. Initially created for anything that would not fit in the other folders.
/homeHome Directory : all files related to users (documents, pictures, etc…).
/libLibraries : contains all libraries or dependencies necessaries for the binaries in /bin and /sbin. It contains the important kernel modules, like drivers for all the peripherals (soundcard, wifi, … ). Linux distributions may have variants /lib32 and /lib64 for multi-architecture support.
/mediaMedia : Default mount point for removable devices (usb sticks, CD Rom, …).
/mntMount : Temporarily mounted filesystems.
/optOptional add-on software packages. It can also be used to contain locally build software. It would also contains bin and lib subfolders. Nowadays /usr/local is prefered to /opt.
/procProcess : virtual directory that contains information about the computer such as cpu, memory, OS version , …
/rootSuperuser home directory. Always on the initial filesystem to make sure it is always available during maintenance periods.
/runTemporary folder : contains volatile runtime data.
/sbinSystem Binaries : (or superuser binaries) contains fundamental utilities such as init required to start, maintain or recover the system. Requires the use of superuser or sudo.
/srvServer data : can be used to host html pages served through a web server or files hosted by an sftp server. In that case subfolders are created, like /srv/www and /srv/ftp.
/sysSystem : virtual directory that contains information only on devices connected to the computer. Touch with care as it may crash the system.
/tmpTemp : contains temporary files used by applications running by the users. Normally should be cleaned up upon startup.
/unixUnix kernel : contains kernel files for Research Unix and System V. Sometime can be used also for the virtual memory.
/usrUser File System : holds executables, libraries and shared ressources that are not system critical (Window managers, scripting languages, …).
/usr/binUser Binaries.
/usr/includeInclude files : Headers files used mostly when developping in C.
/usr/libUser Libraries.
/usr/libexecLibrary Executables : Contains executable that are executed by other programs rather than directly by users.
/usr/localAdditions for the operating systems (that are not part of it).
/usr/shareProgram Data : Architecture-Independent data contained in subdirectories. For instace, man subdirectory will contain content for manpage.
/varVariable : contains file that can change over time, such as logs, spool, etc…
/var/logLogs.
/var/mailMail location for all incoming emails.
/var/spoolSpool directory : contains print jobs, or other queued tasks.
/var/srcSource : contains uncompiled code for some programs.
/var/tmpcontains temporary files that should be preserved between reboots.

Utilities

CommandDescription
cdChange Directory, used to navigate
mkdirMake Directory, to create a new directory
pwdPrint Current Directory
rmdirRemove Directory, to delete an empty directory
treeNice tool to visualize the hierarchy in a Terminal window.

References