Linux Directory Structure Explained: What Every Folder in / Is For

Cyber Security3 min read
Linux directory structure: root, etc, var, home, proc explained
On this page

Linux organises everything in one tree that starts at the root directory, /. Disks, USB drives and even kernel information appear as folders inside this tree. The layout follows the Filesystem Hierarchy Standard (FHS), so once you know it, you can find your way around almost any Linux system, from a Raspberry Pi to a cloud server.

The main directories

DirectoryWhat it contains
/Root of the whole tree
/bin, /sbinEssential commands and system binaries (on modern systems often links into /usr)
/bootKernel, initramfs and boot loader files
/devDevice files: disks (/dev/sda, /dev/nvme0n1), terminals, /dev/null
/etcSystem-wide configuration files
/homeUsers’ home directories
/rootThe root user’s home directory
/lib, /lib64Shared libraries and kernel modules
/media, /mntMount points for removable media and temporary mounts
/optOptional, self-contained third-party software
/procVirtual view of processes and kernel state
/runRuntime data since the last boot (PID files, sockets)
/srvData served by the system (web or FTP content on some setups)
/sysVirtual view of devices and drivers
/tmpTemporary files, often cleared on reboot
/usrInstalled programs, libraries and documentation
/varVariable data: logs, caches, mail, databases, spool files

Directories worth knowing well

/etc: configuration. Examples: /etc/passwd (accounts), /etc/shadow (password hashes, root only), /etc/hosts, /etc/ssh/sshd_config, /etc/crontab.

/var/log: logs. /var/log/auth.log or /var/log/secure (logins and sudo), /var/log/syslog or /var/log/messages, web server logs under /var/log/nginx or /var/log/apache2. On systemd systems, journalctl reads the journal.

/proc: live kernel information as files. /proc/cpuinfo, /proc/meminfo, and a folder per process (/proc/1234/cmdline, /proc/1234/exe, /proc/1234/fd). Tools like ps aux and top read their data from here.

/dev: devices. Forensic imaging tools such as dc3dd read disks from /dev/sdX.

Useful commands for exploring

ls -la /etc            list with hidden files and permissions
tree -L 1 /            show the top level as a tree
du -sh /var/* 2>/dev/null | sort -h    which folders use the most space
df -h                  free space per mounted file system
findmnt                what is mounted where

Linux structure for security and forensics

Attackers and investigators look in the same places:

LocationWhy it matters
/etc/passwd, /etc/shadow, /etc/sudoersAccounts and privileges
/etc/cron*, /var/spool/cron, systemd unit filesPersistence
/home/*/.ssh/authorized_keysBackdoor SSH keys
/tmp, /dev/shm, /var/tmpDropped tools and payloads (world-writable)
/var/logEvidence of logins, commands and attacks
/proc/PID/exeThe real executable of a suspicious process, even if deleted

Frequently asked questions

What is the root directory in Linux?

The top of the file system tree, written as /. Everything else is inside it. It is different from /root, the root user’s home folder.

What is the difference between /bin and /usr/bin?

Historically /bin held essential commands and /usr/bin the rest. Many modern distributions merged them, with /bin linking to /usr/bin.

Where are configuration files in Linux?

Mostly in /etc for the whole system, and in hidden files and folders in each user’s home directory.

Where are logs stored in Linux?

In /var/log, and on systemd systems in the journal, read with journalctl.

What is /proc?

A virtual file system that exposes running processes and kernel information as files.

Learn Linux the practical way

Our free Linux command line cheat sheet and the Assembly and Shellcode Development course take you from navigating the file system to how Linux runs programs. See also Linux pipes and redirection.

Written by

Taifun Mamedov

Founder and instructor at Ocsaly Academy.

Courses by Taifun Mamedov

Share this article