🐧 Ultimate Guide to Linux Directories & Files

Jitendra KumarJitendra Kumar
5 min read

If you’re stepping into the world of Linux, understanding its file system hierarchy is crucial. Think of it like learning your way around a cityβ€”once you know where everything is, using it becomes second nature. This guide will take you from the basics to expert-level knowledge about Linux directories, their roles, important files, and even symbolic links (shortcuts).

πŸ” What Is the Linux File System?

The Linux file system is the structure where data is stored, organized, and accessed. Unlike Windows (which uses drive letters like C:, D:), Linux uses a tree-like structure starting at a single root directory: / .

🧾 Basic Terms to Know:

  • Directory: A folder used to group files.

  • File: A data container (text, binary, config, etc.)

  • Root (/ ): The topmost directory in the hierarchy.

  • Symlink (Symbolic Link): A shortcut or reference to another file/directory.

🌲 The File System Tree Overview

Everything starts from / (root). All files and folders branch out from here.

/
β”œβ”€β”€ bin
β”œβ”€β”€ boot
β”œβ”€β”€ dev
β”œβ”€β”€ etc
β”œβ”€β”€ home
β”œβ”€β”€ lib -> usr/lib
β”œβ”€β”€ lib64 -> usr/lib64
β”œβ”€β”€ media
β”œβ”€β”€ mnt
β”œβ”€β”€ opt
β”œβ”€β”€ proc
β”œβ”€β”€ root
β”œβ”€β”€ run
β”œβ”€β”€ sbin -> usr/sbin
β”œβ”€β”€ srv
β”œβ”€β”€ sys
β”œβ”€β”€ tmp
β”œβ”€β”€ usr
└── var

πŸ” Notice: Some directories like /lib , /sbin , and /bin are now symlinks pointing to /usr/lib , /usr/sbin , and /usr/bin on modern Linux systems.

🧰 In-Depth Directory Breakdown

Let’s explore each directory in detail with examples, real-world use, and shortcut (symlink) info.

πŸ“¦ /bin – Essential User Commands

  • Purpose: Contains basic executable programs and command-line tools required by all users.

  • Examples: ls , cp , mv , rm , cat

  • Access: Available to all users.

  • Important: Needed during system recovery.

πŸ” On newer distros, /bin is a symlink to /usr/bin .

βš™οΈ /sbin – System Binaries

  • Purpose: Holds system-level utilities mainly used by the root (admin) user.

  • Examples: fsck , reboot , shutdown , ifconfig

  • Access: Restricted to root for system maintenance.

πŸ” Typically symlinked to /usr/sbin .

🧠 /boot – Boot Loader Files

  • Purpose: Contains all files required to boot the system.

  • Includes: Kernel files (vmlinuz), initrd, grub config files.

  • Caution: Messing with this can break your system!

πŸ“ Example files:

/boot/grub/grub.cfg
/boot/vmlinuz-5.15.0

πŸ§ͺ /dev – Device Files

  • Purpose: Represents system devices as files.

  • Type: Virtual, dynamically managed by the kernel (udev).

  • Examples:

    • /dev/sda β†’ Hard disk

    • /dev/tty β†’ Terminals

    • /dev/null β†’ β€œBlack hole” file

  • 🧠 Why? Because in Linux, everything is a fileβ€”including hardware.

πŸ” /etc – Configuration Files

  • Purpose: Houses all system-wide configuration files and directories.

  • DO NOT store personal data here.

  • Examples:

    • /etc/passwd : List of system users

    • /etc/ssh/sshd_config : SSH settings

    • /etc/fstab : Filesystem mount table

🧠 Most services (like networking, cron jobs, etc.) read their settings from /etc .

🏠 /home – User Home Directories

  • Purpose: Personal directories for every user (non-root).

  • Layout: /home/username/

  • What’s Inside: Documents, Pictures, Downloads, personal app settings

πŸ’‘ Each user can modify files in their own home but not in others’ or system directories.

πŸ‘‘ /root – Root User’s Home

  • Purpose: Home directory of the superuser.

  • Not to be confused with / (root of the file system).

  • Path: /root/ (not under /home!)

πŸ›‘ Only accessible by the root user.

🧬 /lib and /lib64 – Shared Libraries

  • Purpose: Contains essential shared libraries needed by binaries in /bin and /sbin.

  • 64-bit Systems: Use/lib64 for 64-bit libraries.

πŸ” These are often symbolic links to /usr/lib and /usr/lib64 .

πŸ“‚ /media and /mnt – Mount Points

  • /media : Auto-mounted external devices (USBs, DVDs)

  • /mnt : Temporary mount point for system admin (manual)

🧠 Mounting means linking a device to the file system so it becomes accessible.

πŸ’Ό /opt – Optional Software Packages

  • Purpose: For third-party software that doesn’t fit into standard paths.

  • Example: Google Chrome or proprietary software installations.

πŸ—‚οΈ Often used for large software suites.

🧾 /proc – Process Info (Virtual Filesystem)

  • Purpose: Dynamic, virtual files showing system and process info.

  • Managed by: Kernel

  • Examples:

    • /proc/cpuinfo : CPU details

    • /proc/meminfo : Memory usage

    • /proc/[PID]/ : Info about a specific process

  • 🧠 These files don’t exist on diskβ€”they’re created in real time!

πŸ” /run – Runtime Data

  • Purpose: Stores volatile runtime info (like PID files) needed between boot and services.

  • Cleared at: Every reboot.

  • Used by: systemd, network services, login sessions

πŸ—ƒοΈ /srv – Service Data

  • Purpose: Contains data for services like FTP, HTTP, etc.

  • Examples:

    • /srv/ftp/

    • /srv/www/

  • πŸ‘¨β€πŸ’» Useful for servers hosting public services.

⚠️ /tmp – Temporary Files

  • Purpose: Temp files created by applications.

  • Auto-cleared: On reboot or scheduled cleanup.

  • Examples:

    • Download caches

    • Unzipped install files

🧼 Never store important data here!

🌐 /usr – User System Resources (Not β€œHome” Users)

  • Purpose: Contains application binaries, libraries, docs not critical to boot.

  • Structure:

    • /usr/bin : User-level commands

    • /usr/lib : Libraries

    • /usr/share : Shared documentation, icons

πŸ’‘ On modern distros, this is the core of most Linux software.

πŸ“Š /var – Variable Files

  • Purpose: Data that changes frequently.

  • Includes:

    • Logs (/var/log )

    • Mail spools

    • Print queues

    • Databases

πŸ“‰ If your system runs out of space, /var is often the culprit.

🧩 Which Directories Are Symlinks?

Here are the most common symlinked directories:

DirectorySymlink ToPurpose
/bin/usr/binBasic commands
/sbin/usr/sbinSystem commands
/lib/usr/libShared libraries
/lib64/usr/lib6464-bit libraries

These symlinks ensure backward compatibility and maintain a cleaner structure under /usr.

πŸ“Œ Key System Files to Know

FileDescription
/etc/passwdUser account details
/etc/shadowEncrypted user passwords
/etc/fstabAuto-mount drives
/etc/hostnameSystem hostname
/etc/hostsLocal DNS mappings
/var/log/syslogSystem logs
/proc/cpuinfoCPU info
/etc/resolv.confDNS resolver settings

🧭 Why Learning the Linux File System Matters

Mastering the file system allows you to:

βœ… Troubleshoot faster

βœ… Understand where apps store data

βœ… Secure your system better

βœ… Automate tasks using the terminal

βœ… Feel confident working with Linux πŸ’ͺ

0
Subscribe to my newsletter

Read articles from Jitendra Kumar directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Jitendra Kumar
Jitendra Kumar