Linux File System Structure Explained Simply
In this article
The Linux file system is a tree-like hierarchy starting at the root (/). Everything—files, devices, even running processes—appears as a file or directory under this root. Understanding the standard directories helps you navigate any Linux system, find configuration files, and know where your data belongs. You don't need any special tools—just a terminal and a willingness to explore.
What You'll Need
- A Linux system (any distribution) with terminal access.
- Basic familiarity with commands like
cd,ls, andcat(optional but helpful).
Step-by-Step
- Open a terminal. Use your distribution's terminal app (e.g., GNOME Terminal, Konsole, or the built-in terminal on a server). You'll be running read-only commands, so no root privileges are needed.
- View the root directory. Type
ls /and press Enter. You'll see a list of top-level directories. The exact names may vary slightly by distribution, but the core ones are consistent. - Understand the root (
/). This is the top of the tree. Every file and directory on the system hangs off this single point. Unlike Windows (which has C:, D:, etc.), Linux has one unified hierarchy. Other storage devices (USB drives, hard disks) are mounted as subdirectories under/, typically under/mntor/media. - Explore
/binand/sbin. These contain essential executable programs (binaries)./binholds user commands likels,cp, andbash./sbinholds system administration commands likefdiskandifconfig. On modern distributions, both are often symlinks to/usr/binand/usr/sbinrespectively, but the logical separation remains. - Check
/etc. This directory contains system-wide configuration files. For example,/etc/passwdlists user accounts,/etc/fstabdefines filesystem mounts, and/etc/hostnamestores the machine's name. Most configuration here is plain text, editable with any text editor (if you have root permissions). - Look at
/home. This is where regular users' personal directories live. For example, if your username isalice, your personal files are in/home/alice. Each user has their own subdirectory, and only that user (and root) can access it by default. - Understand
/root. This is the home directory for the root user (the system administrator). It's separate from/homebecause root's files should not be mixed with regular users' data, especially in case of a system recovery where/homemight not be mounted. - Inspect
/var. This directory holds variable data—things that change frequently. Key subdirectories include/var/log(system logs),/var/spool(print queues and cron jobs), and/var/tmp(temporary files that persist across reboots). - Examine
/tmp. This is for temporary files created by the system and users. Files here are often deleted on reboot. Don't store anything important here. - Look at
/usr. This is the largest directory. It contains user-installed software and data that is not essential for booting. Subdirectories include/usr/bin(most user commands),/usr/lib(libraries),/usr/share(architecture-independent data like icons and docs), and/usr/local(software compiled manually by the admin). - Explore
/opt. This is for optional or third-party software that is not part of the standard package manager. For example, some commercial applications install here in their own subdirectory. - Understand
/dev. This contains device files that represent hardware components. For example,/dev/sdais typically the first hard disk,/dev/ttyrepresents terminals, and/dev/nulldiscards all data written to it. These are not regular files; they are interfaces to drivers. - Check
/procand/sys. These are virtual filesystems that provide information about running processes and kernel data structures. For example,/proc/cpuinfoshows CPU details, and/sys/classexposes device information. They exist only in memory and are empty on disk. - Look at
/boot. This contains files needed to boot the system, such as the Linux kernel (often namedvmlinuz-*) and bootloader configuration. On UEFI systems, you may also see anEFIsubdirectory. - Understand
/mntand/media./mntis a generic mount point for temporarily mounting filesystems (e.g., a manual mount of an external drive)./mediais used by desktop environments to auto-mount removable media like USB drives and SD cards, usually under subdirectories named after the device label. - Navigate using absolute paths. An absolute path starts from the root, e.g.,
/home/alice/Documents. A relative path starts from your current directory, e.g.,Documentsif you're already in/home/alice. Usecdto change directories andpwdto see where you are. - Use
man hierfor a reference. Typeman hierin a terminal to see the official documentation of the filesystem hierarchy. This is a great quick reference for any directory you're unsure about.
Common Mistakes
- Assuming
/tmpis safe for important data. It's cleared on reboot, and some systems even use a tmpfs that is in RAM, so files vanish when the system shuts down. - Editing files in
/etcwithout a backup. A typo in/etc/fstabor/etc/passwdcan prevent the system from booting. Always back up before editing. - Storing personal files in
/usror/opt. These are for system-managed software. Your files belong in/home. - Deleting files in
/devor/proc. These are virtual—deleting them can break device access or system monitoring. Never delete anything there unless you're absolutely sure. - Confusing
/binand/sbin. On older systems,/sbinrequired root privileges to run. On modern systems, both are usually accessible to all users, but the distinction is still useful for understanding system design.
Tips
- Use
ls -lto see file types. The first character of the permissions string indicates type:dfor directory,lfor symlink,-for regular file. - Use
df -hto see disk usage. This shows which filesystems are mounted and how much space they use. It helps you understand where data actually resides. - Explore with
treeif installed. Thetreecommand shows a visual tree of directories. Install it with your package manager if not present. - Remember that case matters.
/Homeand/homeare different directories. Always use the correct case. - Use symlinks to understand aliases. For example,
/binis often a symlink to/usr/bin. Runls -l /binto see the link.
Troubleshooting
- If you can't see a directory you expected, check if it's a symlink. Use
ls -l /pathto see if it points elsewhere. Some distributions use symlinks to merge directories (e.g.,/bin→/usr/bin). - If you get "Permission denied" when listing a directory, it may be that the directory's permissions don't allow read access for your user. Use
ls -ld /pathto check permissions. For system directories like/root, you'll need root privileges. - If a command like
treeis not found, install it via your package manager (e.g.,sudo apt install treeon Debian/Ubuntu,sudo dnf install treeon Fedora). - If you accidentally delete a file in
/tmpthat you needed, it's gone. There's no recovery unless you have a backup. This is why you should never rely on/tmpfor important data. - If you're unsure what a directory is for, run
man hieror search online. The official Filesystem Hierarchy Standard (FHS) is a good reference.
Frequently Asked Questions
Why does Linux use a single root directory instead of drive letters?
Because everything is a file, and the root directory is the base of the file tree. Drives are mounted as subdirectories, which simplifies access and allows for flexible storage layouts.
What is the difference between /bin and /sbin?
Historically, /bin held essential user binaries and /sbin held system administration binaries. Today, on many systems, both are symlinks to /usr/bin and /usr/sbin, but the logical separation remains.
Can I change the location of my home directory?
Yes, but it's not trivial. You can edit /etc/passwd or use the usermod -d command. However, you must move your files and ensure permissions are correct. It's not recommended for beginners.
What is the /etc directory for?
It holds system-wide configuration files. Almost every service and application that has system-wide settings stores them here in plain text.
Why are there so many directories that look similar?
Linux follows the Filesystem Hierarchy Standard (FHS) to maintain consistency across distributions. The separation (e.g., /usr vs. /opt) helps with package management and system maintenance.
Is it safe to delete files in /var/log to free space?
You can delete old log files, but it's better to use logrotate to manage them automatically. Deleting active log files may cause the system to keep writing to a deleted inode, which can fill up the disk. It's safer to truncate them (e.g., sudo truncate -s 0 /var/log/syslog).