π§Linux File System
Understand cd, ls, chmod, chown, and mount by first understanding how Linux actually organizes its files.
The Linux File System is one of the most important Linux topics to understand. Once you get how itβs organized, commands like cd, ls, find, chmod, chown, and mount stop feeling random and start making complete sense. Let's break it down from the ground up.
1. What is a File System?
A file system is the way an operating system organizes and stores files and folders on a storage device.
For example, your computer has:
Documents
Pictures
Downloads
VideosLinux also has files and directories, but its structure is different from Windows.
The most important thing to remember is:
Linux starts its entire file system from
/(root).
2. Linux File System Starts from /
In Windows, you may see:
C:\
D:\
E:\In Linux, you normally have:
/Everything is connected under /. Think of / as the main building:
/
ROOT DIRECTORY
β
βββββββββββ¬ββββββββΌβββββββββ¬ββββββββββ
β β β β β
/home /etc /var /usr /tmp3. Complete Linux File System Structure
A typical Linux system looks something like this:
/
βββ bin
βββ boot
βββ dev
βββ etc
βββ home
βββ lib
βββ lib64
βββ media
βββ mnt
βββ opt
βββ proc
βββ root
βββ run
βββ sbin
βββ srv
βββ sys
βββ tmp
βββ usr
βββ varβ οΈ The exact structure can differ between distributions and versions. Modern distributions often merge directories such as /bin into /usr/bin.
Now letβs go through every important directory.
4. / β Root Directory
This is the top of the entire Linux file system. Everything starts here.
For example, in the path:
/home/user/file.txtthe path starts from /.
/= The starting point of the whole file system.
5. /home β Normal Users' Files π€
This directory contains the personal directories of normal users.
/home/kinza/
βββ Desktop
βββ Documents
βββ Downloads
βββ Music
βββ Pictures
βββ Videos
/home= personal area for normal users.
Run cd /home then ls, and you'll see something like user1, user2.
6. /root β Root User's Home
This one confuses beginners.
/ means the root of the entire file system. /root means the home directory of the root user.
/root
βββ .bashrc
βββ .config
βββ files
/= filesystem root Β·/root= root user's home
7. /etc β Configuration Files βοΈ
One of the most important directories. It holds most system configuration files.
/etc/hosts
/etc/passwd
/etc/group
/etc/fstab
/etc/ssh/
/etc/systemd//etc/hostsβ local hostname-to-IP mappings/etc/passwdβ user account information/etc/groupβ group information/etc/fstabβ filesystems that mount automatically
/etc= Linux settings/configuration.
8. /var β Changing Data
var means variable β this stores data that changes frequently.
/var/log
/var/cache
/var/lib
/spoolThe most important one for cybersecurity is /var/log.
9. /var/log β System Logs π
Logs record events happening on the system: login attempts, service events, errors, authentication events. A SOC analyst works with logs constantly.
ls /var/logOn some Debian-based systems you may see auth.log and syslog. Modern systems using systemd also use:
journalctl
/var/log= important place for system/application logs.
10. /tmp β Temporary Files
tmp means temporary. Programs store temporary files here, which may be cleaned up automatically depending on system policy.
/tmp= temporary files.
11. /boot β Boot Files π
Contains files needed during the boot process: the Linux kernel, initramfs, and GRUB-related files.
Computer ON
β
UEFI/BIOS
β
Bootloader
β
Kernel
β
Linux starts12. /dev β Device Files π
Linux represents many devices as special files here.
/dev/sda
/dev/nvme0n1
/dev/null
/dev= device-related files.
13. /proc β Process and System Information π§
/proc is a virtual filesystem β it isn't stored permanently on disk. The kernel generates it live, containing information about processes, CPU, memory, and the kernel itself.
cat /proc/cpuinfo
cat /proc/meminfo14. /proc/PID β Information About a Process
If a process has PID 1234, you'll find details under /proc/1234, including files like /proc/1234/status. Very useful for system administration and security investigations.
15. /sys β Hardware and Kernel Information
Like /proc, /sys is a virtual filesystem, exposing hardware, device, driver, and kernel subsystem info.
/proc β processes/system information
/sys β devices/hardware/kernel information16. /usr β User Programs and Data
A large, important directory containing programs, libraries, documentation, and shared data.
/usr/bin
/usr/sbin
/usr/lib
/usr/share/usr/bin
Contains many user commands (ls, cat, grep, python).
/usr/sbin
Contains system administration programs.
/usr/lib
Contains libraries used by programs.
/usr/share
Contains architecture-independent shared data β documentation, icons, man pages.
17. /bin and /sbin β Essential Commands
Historically /bin held essential commands (ls, cp, mv, cat) and /sbin held admin commands.
On many modern distributions, both are now symbolic links:
/bin -> /usr/bin
/sbin -> /usr/sbinThis is part of a design called usr merge.
18. /lib and /lib64
Contain libraries needed by programs and, traditionally, by the system during boot. On modern systems, these may also be part of the /usr merge.
19. /opt β Optional Software
Used for additional or optional software, e.g. /opt/application.
/opt= optional/additional applications.
20. /mnt β Temporary Mount Point
/mntis commonly used as a location where a filesystem can be manually mounted.
Get Kinzaβs stories inΒ yourΒ inbox
Join Medium for free to get updates fromΒ thisΒ writer.
For example:
USB/partition
β
mount
β
/mntExample:
mount /dev/sdb1 /mntNow the filesystem can be accessed through:
/mnt21. /media β Removable Devices
/mediais commonly used for removable devices such as:
- USB drives
- External storage
- CDs/DVDs
Desktop Linux systems often automatically mount removable devices somewhere under /media.
22. /run β Runtime Information
Contains temporary runtime information created after boot β PID files, sockets, service runtime data. Doesnβt survive a reboot.
23. /srv β Service Data
Intended for data served by system services (e.g. website or FTP data).
24. /lost+found
Found on ext2/ext3/ext4 filesystems β used by recovery tools to store recovered file fragments after a filesystem check.
25. The Full Linux File System Tree
/
β
βββ /bin β Essential commands
βββ /boot β Boot files
βββ /dev β Device files
βββ /etc β Configuration files
βββ /home β Normal users' files
βββ /lib β Libraries
βββ /media β Removable media
βββ /mnt β Temporary mount point
βββ /opt β Optional software
βββ /proc β Process/system information
βββ /root β Root user's home
βββ /run β Runtime information
βββ /sbin β System commands
βββ /srv β Service data
βββ /sys β Hardware/kernel information
βββ /tmp β Temporary files
βββ /usr β Programs/libraries/shared data
βββ /var β Changing data/logs26. What is a Path?
A path tells Linux where a file or directory is located.
/home/user/Documents/file.txt/
βββ home
βββ user
βββ Documents
βββ file.txt27. Absolute vs Relative Paths
An absolute path starts from /:
/etc/passwdA relative path doesnβt. If youβre already in /home/user, then:
cd Documentsgets you to /home/user/Documents β that's a relative path.
28. . and ..
.means the current directory β e.g../script.shruns a script from where you are...means the parent directory β e.g. runningcd ..from/home/user/Documentstakes you to/home/user.
29. ~ β Home Directory
~ represents the current user's home directory. If your username is kinza, then ~ means /home/kinza. Running cd ~ takes you home instantly.
30. βEverything is a Fileβ in Linux
Youβll often hear: βEverything in Linux is a file.β This is a useful simplification β Linux uses a file-like interface for regular files, directories, devices, pipes, and sockets. Donβt take it too literally though; some kernel objects arenβt ordinary files. The real idea is that Linux gives you one common way to interact with many different system resources.
31. Types of Files
Run ls -l and check the first character:
- β Regular file (e.g. -rw-r--r--)
d β Directory (e.g. drwxr-xr-x)
l β Symbolic link (e.g. lrwxrwxrwx)
c β Character device
b β Block device
p β Named pipe
s β Socket32. File Permissions π
Linux controls file access through permissions:
r = read
w = write
x = executeapplied across three categories: Owner, Group, Others.
- rwx r-x r--
β β β
β β βββ Others
β ββββββββ Group
βββββββββββββ Owner33. Permission Numbers
Read = 4
Write = 2
Execute = 1So rwx = 7, rw- = 6, r-x = 5, r-- = 4.
chmod 755 file.shmeans Owner = rwx, Group = r-x, Others = r-x.
34. Ownership
Every file has an owner and a group:
ls -l-rw-r--r-- user user file.txtChange ownership with:
chown35. Inodes
An inode stores metadata about a file: type, permissions, owner, group, size, timestamps, and pointers to its data blocks. It normally does not store the filename itself.
Filename
β
Directory entry
β
Inode
β
File dataSee inode numbers with ls -i.
36. Directories
A directory is a filesystem object that organizes filenames and links them to their inode information.
Documents/
βββ report.txt
βββ notes.txt
βββ image.jpg37. Mounting
Linux connects a filesystem to a directory through mounting.
USB filesystem
β
mount
β
/mnt/usbCheck mounted filesystems with mount, findmnt, or df -h.
38. Partitions
A storage device can be split into partitions, each of which can hold a filesystem.
/dev/sda1
β
ext4 filesystem
β
mounted at /39. Filesystem Types
- ext4 β very common Linux filesystem
- XFS β common in enterprise/server environments
- Btrfs β snapshots and checksumming
- FAT32 / exFAT β removable storage and compatibility
- NTFS β Windows filesystem, also accessible on Linux with support
40. Checking Disk and Directory Size
df -hshows filesystem disk usage (human-readable).
du -sh Downloadsshows the total size of a directory.
41. Everyday Navigation Commands
lsβ list files,ls -lfor details,ls -lato include hidden files- Hidden files start with
.(e.g..bashrc,.profile,.config) cd /etc,cd ~,cd ..β move aroundpwdβ prints your current location (Print Working Directory)find /home -name "test.txt"β search for filesgrep "error" logfile.txtβ search text inside files (essential for log analysis)
42. Important File System Commands β Cheat Sheet
Command Meaning pwd Show current directory ls List files ls -la List files including hidden files cd Change directory mkdir Create directory touch Create empty file cp Copy mv Move/rename rm Remove cat Display file contents less Read file page by page find Search for files grep Search text df -h Show filesystem space du -sh Show directory size mount Show/manage mounted filesystems findmnt Show mounted filesystems chmod Change permissions chown Change ownership
43. The Easy Mental Picture π§
Imagine Linux as a big building:
/
Main Building
β
ββββββββββββββΌβββββββββββββ
β β β
/home /etc /var
Users Settings Logs
β
β
Your Files/boot β Starting Linux
/dev β Devices
/etc β Settings
/home β User files
/proc β Process information
/sys β Hardware information
/tmp β Temporary files
/usr β Programs and shared data
/var β Changing data and logs
/root β Root user's homeβ The Most Important Directories to Memorize
If youβre learning Linux for Cybersecurity/SOC work, start with these:
/ β Top of filesystem
/home β User files
/root β Root user's home
/etc β Configuration
/var/log β Logs
/tmp β Temporary files
/dev β Devices
/proc β Process/system information
/sys β Hardware/kernel information
/usr/bin β Programs/commands
/boot β Boot filesOne-line memory trick:
/etc= settings,/home= users,/var/log= logs,/tmp= temporary,/dev= devices,/proc= processes,/boot= boot,/usr= programs.
Wrapping Up
Once the Linux file system stops looking like a random pile of folders and starts looking like an organized building β settings in /etc, logs in /var/log, users in /home, devices in /dev β every command you run starts to make sense in context. Architecture told you how Linux works; the file system tells you how Linux organizes everything. Together, they're the real foundation for anything you do next, whether that's system administration, scripting, or cybersecurity.
If you found this useful, follow for more beginner-friendly breakdowns of Linux, cybersecurity, and systems concepts.







