Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Linux File System Structure Explained Simply

· 7 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

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, and cat (optional but helpful).

Step-by-Step

  1. 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.
  2. 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.
  3. 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 /mnt or /media.
  4. Explore /bin and /sbin. These contain essential executable programs (binaries). /bin holds user commands like ls, cp, and bash. /sbin holds system administration commands like fdisk and ifconfig. On modern distributions, both are often symlinks to /usr/bin and /usr/sbin respectively, but the logical separation remains.
  5. Check /etc. This directory contains system-wide configuration files. For example, /etc/passwd lists user accounts, /etc/fstab defines filesystem mounts, and /etc/hostname stores the machine's name. Most configuration here is plain text, editable with any text editor (if you have root permissions).
  6. Look at /home. This is where regular users' personal directories live. For example, if your username is alice, your personal files are in /home/alice. Each user has their own subdirectory, and only that user (and root) can access it by default.
  7. Understand /root. This is the home directory for the root user (the system administrator). It's separate from /home because root's files should not be mixed with regular users' data, especially in case of a system recovery where /home might not be mounted.
  8. 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).
  9. 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.
  10. 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).
  11. 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.
  12. Understand /dev. This contains device files that represent hardware components. For example, /dev/sda is typically the first hard disk, /dev/tty represents terminals, and /dev/null discards all data written to it. These are not regular files; they are interfaces to drivers.
  13. Check /proc and /sys. These are virtual filesystems that provide information about running processes and kernel data structures. For example, /proc/cpuinfo shows CPU details, and /sys/class exposes device information. They exist only in memory and are empty on disk.
  14. Look at /boot. This contains files needed to boot the system, such as the Linux kernel (often named vmlinuz-*) and bootloader configuration. On UEFI systems, you may also see an EFI subdirectory.
  15. Understand /mnt and /media. /mnt is a generic mount point for temporarily mounting filesystems (e.g., a manual mount of an external drive). /media is used by desktop environments to auto-mount removable media like USB drives and SD cards, usually under subdirectories named after the device label.
  16. 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., Documents if you're already in /home/alice. Use cd to change directories and pwd to see where you are.
  17. Use man hier for a reference. Type man hier in 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 /tmp is 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 /etc without a backup. A typo in /etc/fstab or /etc/passwd can prevent the system from booting. Always back up before editing.
  • Storing personal files in /usr or /opt. These are for system-managed software. Your files belong in /home.
  • Deleting files in /dev or /proc. These are virtual—deleting them can break device access or system monitoring. Never delete anything there unless you're absolutely sure.
  • Confusing /bin and /sbin. On older systems, /sbin required 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 -l to see file types. The first character of the permissions string indicates type: d for directory, l for symlink, - for regular file.
  • Use df -h to 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 tree if installed. The tree command shows a visual tree of directories. Install it with your package manager if not present.
  • Remember that case matters. /Home and /home are different directories. Always use the correct case.
  • Use symlinks to understand aliases. For example, /bin is often a symlink to /usr/bin. Run ls -l /bin to see the link.

Troubleshooting

  • If you can't see a directory you expected, check if it's a symlink. Use ls -l /path to 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 /path to check permissions. For system directories like /root, you'll need root privileges.
  • If a command like tree is not found, install it via your package manager (e.g., sudo apt install tree on Debian/Ubuntu, sudo dnf install tree on Fedora).
  • If you accidentally delete a file in /tmp that you needed, it's gone. There's no recovery unless you have a backup. This is why you should never rely on /tmp for important data.
  • If you're unsure what a directory is for, run man hier or 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).