Exploring the Linux Directory Structure


When you're new to Linux, navigating the file system might feel like walking through a maze. But don’t worry—Linux's directory structure is actually well-organized and follows a logical hierarchy. In this blog, we’ll walk through each important directory and include real-life examples of what you’ll find or do in each one.
🗂️ 1. /
– The Root Directory
The base of the entire file system. Everything—files, folders, devices—branches off from here.
📌 Example:
Type cd /
in your terminal to go to the root directory.
cd /
ls
You'll see folders like bin
, etc
, home
, var
, etc.
🔧 2. /bin
– Essential Command Binaries
This is where basic Linux commands live.
📌 Example:
/bin/ls
/bin/cp
Even if the system is in recovery mode, these commands are available to help you troubleshoot.
💻 3. /dev
– Device Files
Linux treats devices as files. Want to access your hard drive or USB? You’ll find them here.
📌 Example:
/dev/sda # First hard disk
/dev/tty0 # Terminal device
⚙️ 4. /etc
– Configuration Files
All system-wide configuration files are stored here.
📌 Example:
/etc/passwd # Contains user account information
/etc/hosts # Maps hostnames to IPs
/etc/ssh/sshd_config # SSH server configuration
You can edit these files using nano
or vim
.
🏠 5. /home
– User Home Directories
Each user gets their own directory inside /home
.
📌 Example:
/home/demo # demo’ personal files
/home/john/.bashrc # John’s shell settings
Everything you download, create, or configure as a user goes here.
📚 6. /lib
– Shared Libraries
Libraries used by essential programs. Think of them as .dll
files in Windows.
📌 Example:
/lib/x86_64-linux-gnu/libc.so.6 # Standard C library
These help programs in /bin
and /sbin
function properly.
💼 7. /opt
– Optional Software Packages
Third-party or custom software is often installed here.
📌 Example:
/opt/google/chrome/ # Chrome browser files
Useful when you install something outside of the standard package manager.
🧰 8. /sbin
– System Binaries
Contains tools for administrative tasks.
📌 Example:
/sbin/reboot
/sbin/ifconfig
Typically used with sudo
access.
🔍 9. /proc
– Process Info
A virtual directory that shows info about running processes.
📌 Example:
/proc/cpuinfo # Details about your CPU
/proc/uptime # How long your system has been running
Try:
/proc/cpuinfo
📁 10. /media
& /mnt
– Mount Points
These are used to access USB drives, external HDDs, or temporary mount points.
📌 Example:
/media/usb # USB drive mounted here
/mnt/data # Temporary storage or shared drive
👑 11. /root
– Root User’s Home Directory
This is not the same as /
. It's the personal home folder for the root
user.
📌 Example:
/root/.bashrc # Root’s shell settings
You won’t see this unless you’re logged in as root or using sudo
.
🔄 12. /run
– Runtime Data
Holds temporary files needed during system boot or while it's running.
📌 Example:
/run/lock
/run/systemd
Usually, you don’t need to mess with this directory.
🧠 13. /sys
– Kernel Device Info
Like /proc
, this provides a view into your system’s kernel and devices.
📌 Example:
/sys/class/net/eth0 # Info about the Ethernet device
🗑️ 14. /tmp
– Temporary Files
Programs store temporary files here.
📌 Example:
/tmp/install.log
/tmp/tmp12345.tmp
Files here are automatically deleted on reboot.
🧑💻 15. /usr
– User Applications and Utilities
It contains applications and files used by regular users.
📌 Example:
/usr/bin/firefox
/usr/share/icons
Try:
which firefox
You’ll likely get something like /usr/bin/firefox
.
📝 16. /var
– Variable Files (Logs, Mail, Cache)
Files that change frequently go here.
📌 Example:
/var/log/syslog # System logs
/var/www/html/index.html # Default web page (Apache)
🧭 Why It Matters
Understanding this layout isn’t just for geeks—it’s practical. Whether you’re trying to:
Fix a broken service
Find a log file
Install software manually
Secure your server
...knowing where to look saves time and frustration.
🧠 Pro Tip for Beginners
When in doubt, don’t delete anything from system directories unless you're really sure what you're doing. It’s easy to break things!
✅ Final Thoughts
Linux is powerful, and a big part of that power lies in its clean, organized filesystem. At first glance, it might seem intimidating, but once you get the hang of it, you'll start to appreciate its logic and flexibility.
Keep exploring, and soon navigating Linux will feel as natural as browsing folders on your desktop!
Subscribe to my newsletter
Read articles from Vikas Rajpurohit directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
