Linux File System Structure and the Filesystem Hierarchy Standard
Learn how Linux organizes files under /, use absolute and relative paths, navigate with pwd, ls, and cd, and understand common directories, mounts, devices, permissions, and FHS conventions.
Linux organizes files and many other resources in a single tree called the filesystem hierarchy. The top of this tree is the root directory, written as /. Every path begins at or can ultimately be reached beneath this directory, including filesystems mounted from other disks, partitions, network shares, or removable devices.
This is different from the root user. The root directory is a location in the filesystem; the root user is the administrative superuser account.
The unified Linux filesystem hierarchy
Linux presents regular files, directories, device interfaces, and several kernel-provided resources through one directory-tree structure. A separate filesystem does not create a second unrelated tree for users to navigate. Instead, it is attached to an existing directory through a mount point.
For example, a system might have one filesystem mounted at / and another mounted at /home. Users still reach personal files with paths such as /home/alex/notes.txt. The contents of the filesystem mounted at /home appear beneath that directory.
Files, directories, and special files
Regular files
A regular file stores data. Examples include text documents, program binaries, images, shell scripts, and configuration files. A regular file can have permissions, an owner, a size, and timestamps.
Directories
A directory is a filesystem object that organizes names for files and subdirectories. It does not simply contain a text list in the way a spreadsheet does; the filesystem maintains directory entries that map names to objects.
Special files
Linux also supports special file types. A symbolic link stores another pathname and redirects access to that pathname. A device node provides a file-like interface to a device or kernel-managed resource. A socket enables communication between processes, and a named pipe provides a filesystem name for a stream used between processes.
When people say that Linux treats many resources as files, they mean that common file operations and pathnames provide a consistent interface to resources such as terminals, devices, process information, and kernel settings. This does not mean every resource is stored as ordinary data on a disk.
Common filesystem object types
| Object type | Long-listing indicator | Purpose | Example |
|---|---|---|---|
| Regular file | - | Stores ordinary data | /etc/hosts |
| Directory | d | Organizes names for objects | /var/log |
| Symbolic link | l | Points to another pathname | /bin on some usr-merged systems |
| Block device | b | Provides block-oriented storage access | /dev/sda |
| Character device | c | Provides stream-oriented device access | /dev/tty |
| Socket | s | Supports process communication | A service socket beneath /run |
| Named pipe | p | Provides a named one-way data stream | A FIFO created by an application |
Pathnames and paths
A pathname, or path, is a sequence of directory names followed by the name of a filesystem object. The slash character separates components. For example, /home/alex/projects/app.py identifies app.py inside projects, inside alex, inside home.
Absolute paths
An absolute path begins with /. It is interpreted from the root directory, regardless of the shell's current location. For example, /etc/hosts identifies the same object no matter which directory the shell is using.
Relative paths
A relative path does not begin with /. The shell and programs interpret it from the current working directory. If the current directory is /home/bob, then file.txt means /home/bob/file.txt.
The path ./file.txt means the same thing in that situation. The component . means the current directory, while .. means the parent directory. The tilde ~ is shell shorthand for the current user's home directory. The hyphen used as cd - means the shell's previous working directory.
| Form or symbol | Meaning | Example | Resolution context |
|---|---|---|---|
/ | Root directory | ls / | Top of the hierarchy |
| Absolute path | Path resolved from root | /home/bob/file.txt | Independent of current directory |
| Relative path | Path resolved from the current directory | file.txt | Depends on current directory |
. | Current directory | ./script.sh | Current directory |
.. | Parent directory | ../shared | Parent of current directory |
~ | Current user's home directory | ~/Downloads | Expanded by the shell |
- | Previous directory for cd | cd - | Shell navigation history |
Current working directory and navigation
Every shell session has a current working directory. Commands use this directory when resolving relative paths. The command pwd prints it, ls lists entries, and cd changes it.
pwd
ls
ls /
cd /home/bob
pwd
cd ..
cd ~
cd -
cd / moves directly to the root directory. cd .. moves to the parent of the current directory. cd ~ moves to the current user's home directory. cd - returns to the directory used before the most recent directory change.
For example, when the current directory is /home/bob, both file.txt and ./file.txt refer to /home/bob/file.txt. From /var, the same relative path refers to /var/file.txt instead.
cd /home/bob && pwd
ls -ld / /home /etc /usr /var /dev
Filesystem Hierarchy Standard
The Filesystem Hierarchy Standard (FHS) is a convention describing the intended purposes and usual locations of directories in Linux-like systems. It helps administrators and software developers predict where configuration, programs, logs, libraries, and user data are normally placed.
Distributions generally follow these conventions, but details vary. A directory's intended purpose does not guarantee that every installation has the same files, subdirectories, packages, or mount layout. Desktop, server, container, embedded, and distribution-specific systems can all differ.
Common Linux top-level directories
| Directory | Primary purpose | Typical contents | Notes and modern variations |
|---|---|---|---|
/ | Root of the hierarchy | Top-level directories such as /etc, /usr, and /var | All accessible mounted locations are reached beneath it |
/bin | Essential user command binaries | Basic commands traditionally needed for normal use and recovery | Often merged with or symbolically linked to /usr/bin |
/boot | Boot-related files | Bootloader files, kernel images, and initial RAM filesystem images | May be a separate filesystem |
/dev | Device nodes and kernel interfaces | Disks, terminals, null devices, and other device entries | Usually populated dynamically |
/etc | System-wide configuration | Service settings, account databases, networking configuration | Configuration is generally text-based, but formats vary |
/home | Regular users' home directories | /home/alex, /home/bob | Conventional; administrators can configure another location |
/lib and /lib64 | Essential shared libraries and kernel modules | Runtime libraries and modules needed by core programs | May be merged into /usr/lib; /lib64 is architecture-dependent |
/media | Removable-media mount points | USB drives, optical media, and similar devices | Common on desktop systems; layout is configurable |
/mnt | Temporary manual mount point | A filesystem mounted for short-term administration | Often used for manually mounted storage |
/opt | Optional application software | Third-party or self-contained application packages | Usage differs by vendor and distribution |
/proc | Kernel and process information | Process directories and kernel status or configuration interfaces | A virtual filesystem, not ordinary disk storage |
/root | Root user's home directory | Administrative user's personal files and shell configuration | Distinct from the root directory / |
/run | Runtime data created since boot | Process IDs, sockets, locks, and service state | Usually temporary and recreated during boot |
/sbin | Essential system-administration commands | Commands traditionally used for system maintenance | Often merged with or linked to /usr/sbin |
/srv | Data served by system services | Possible web, file-transfer, or repository data | Optional; service-specific layouts are common |
/sys | Kernel device and system information | Device, driver, bus, and kernel attribute interfaces | A virtual filesystem generated by the kernel |
/tmp | Temporary storage | Short-lived files created by users and programs | Contents may be cleaned automatically |
/usr | Major user-space software hierarchy | Programs, libraries, documentation, and shared read-only data | Often treated as relatively stable; it contains /usr/bin and /usr/share |
/var | Variable system and application data | Logs, caches, databases, spool files, and state | Can grow substantially and may be a separate filesystem |
Important subdirectories
/usr/bin: Common user-space command binaries./usr/sbin: System-administration and service-management commands./usr/lib: Shared libraries, program support files, and architecture-specific components./usr/local: Software and data installed locally by an administrator rather than normally managed by the distribution package system./usr/share: Architecture-independent data such as documentation, locale data, icons, and manuals./var/log: System and application logs./var/tmp: Temporary files that are generally intended to survive a reboot longer than files in/tmp, although cleanup policies vary./var/cache: Reusable cached data that programs can usually regenerate./var/lib: Persistent application and system state, such as package databases or service databases./var/spool: Queued work, including print jobs, mail queues, and scheduled-job data./procand/sys: Virtual filesystem interfaces exposing process, kernel, device, and system information./lost+found: A recovery directory that may appear at the top of ext-family filesystems after filesystem creation or repair.
Device files in /dev
A device node is a special file, normally located in /dev, that gives programs a file-like interface to a hardware device or kernel-managed resource. A block device transfers data in blocks and commonly represents a disk or partition. A character device transfers data as a stream of characters, as with a terminal.
/dev/sdais a traditional name for a storage device./dev/nvme0n1is an example of an NVMe storage device name./dev/ttyrepresents the controlling terminal interface./dev/nulldiscards data written to it and reports end-of-file when read./dev/zerosupplies zero bytes when read./dev/randomprovides random data through a kernel interface.
ls -l /dev/null /dev/zero
Mount points and multiple filesystems
A disk, partition, network share, or removable device contains a filesystem that can be attached to the directory tree. The directory where it is attached is the mount point. After mounting, the filesystem's contents appear at that path.
The root filesystem is mounted at /, but /home, /boot, or a removable-media directory may each be a separate filesystem. A mount hides the directory's previous contents while the mount is active; those original contents become visible again when the filesystem is unmounted.
findmnt
df -hT
findmnt displays the mounted filesystem tree and mount points. df -hT reports filesystem capacity, filesystem type, and mount location. These commands are useful when expected files are missing or when checking whether a directory is a separate filesystem.
Permissions and directory access
Filesystem objects have an owner, a group, and permissions. The basic permission categories are read, write, and execute, applied separately to the owner, group, and others.
For a regular file, read permits reading content, write permits modification, and execute permits execution when the file is otherwise suitable. For a directory, read permits listing names, write permits creating or removing entries, and execute permits traversal through the directory and access to objects beneath it. Therefore, a user may see a directory but still receive a permission error when entering it or accessing a particular file.
ls -ld /etc /var/log /home
stat /etc /var/log
Permission errors commonly occur when a user attempts to list, enter, create files in, or modify administrative directories without the required permissions. Inspect the path, ownership, and permission bits before deciding whether administrative access is appropriate.
Modern distribution variations and usr merge
Many current systems use usr merge. In this layout, traditional directories such as /bin, /sbin, and /lib may be symbolic links to corresponding locations beneath /usr, such as /usr/bin, /usr/sbin, and /usr/lib. Other systems may use directories that are operationally unified in a different way.
ls -ld /bin /usr/bin /sbin /usr/sbin
readlink -f /bin
stat /bin /usr/bin
Seeing the same commands through /bin and /usr/bin is normal on a usr-merged system. Likewise, /home and /media are conventions, not unchangeable requirements. Containers, servers, embedded systems, and different distributions can have different contents or omit directories that are unnecessary for their role.
Practical inspection exercises
Inspect the root hierarchy
ls /
ls -ld / /home /etc /usr /var /dev
Identify familiar entries such as etc, home, usr, var, dev, and tmp. The exact list depends on the system.
Compare file types
ls -l /dev/null /dev/zero
ls -l /path/to/regular-file /path/to/symbolic-link
The first character in a long listing indicates the object type: - for a regular file, d for a directory, l for a symbolic link, b for a block device, and c for a character device. Use an available regular file and symbolic link when the example paths do not exist on your system. For another method of identifying file types, see Determine File Type.
Compare stable configuration and changing data
ls /etc
ls /var/log
/etc primarily contains system-wide configuration, while /var/log contains changing records produced by the system and applications. Access to logs may require appropriate group membership or administrative privileges.
Troubleshooting path and filesystem problems
cd: No such file or directory
- Check the current location with
pwd. - Check the parent directory with
lsorls path-to-parent. - Look for misspelled path components.
- Try the intended absolute path.
- Check whether the expected filesystem is mounted with
findmntordf -hT.
Permission denied
- Inspect the directory with
ls -ld PATH. - Check its owner, group, and permission bits.
- Remember that directory execute permission controls traversal.
- Do not bypass permissions unless administrative access is appropriate for the task.
Expected files are missing beneath a mount point
The filesystem might not be mounted, or another filesystem might be mounted over the directory and hiding its original contents. Run findmnt TARGET or df -hT, check the intended mount configuration, and verify that the path matches the conventions used by the distribution.
A device path does not exist
Do not assume every disk is named /dev/sda. Systems may use names such as /dev/nvme0n1 or /dev/vda.
ls /dev
lsblk
Use the available device listings and lsblk to inspect recognized block devices. A missing entry can also indicate undetected or unavailable hardware.
Exam-relevant distinctions
/versus/root:/is the root directory;/rootis the root user's home directory.- Absolute versus relative: an absolute path begins with
/; a relative path depends on the current working directory. /etcversus/var:/etcholds system configuration;/varholds changing data such as logs and caches./tmpversus/var/tmp: both hold temporary data, but cleanup and expected persistence differ by policy./dev: contains device nodes, not ordinary copies of hardware data./procand/sys: are virtual filesystems generated by the kernel.- FHS: defines conventional purposes, not an identical mandatory directory listing on every Linux installation.
- usr merge:
/bin,/sbin, and/libmay point into/usr.
For further shell context, review Bourne Again Shell Bash, and for command lookup behavior see Show The Full Path Of Shell Commands. The broader Linux topic index is available at Linux.