Mastering the Linux File System: Structure, Permissions & Security — A Complete Beginner-to-Advanced Guide
Explore the Linux file system in this complete beginner-to-advanced guide. From understanding the directory structure and permissions to learning how mounting, special bits, and system files actually work, this article simplifies Linux fundamentals with clear explanations and practical commands. Whether you're new to Linux or looking to strengthen your system administration and security skills, this guide will help you confidently navigate and secure any Linux machine.

SECTION 1 — INTRODUCTION
Linux powers everything — from cloud servers, DevOps pipelines, cybersecurity labs, routers, mobile devices, and even CTF boxes. Whether you're a developer, sysadmin, or an aspiring cybersecurity professional, understanding the Linux file system is one of the most foundational skills you must master.
Unlike Windows, where files live inside different drives such as C: or D:, Linux follows a single unified directory structure that begins at / — the root of the system. Every file, directory, device, socket, and even processes are represented as a file.
This unique approach makes Linux extremely powerful, predictable, and flexible — but also confusing for beginners who see folders like /etc, /var, /usr, /mnt, and wonder what they actually contain.
In this blog, we break down the Linux File System Hierarchy in a simple, practical, and exam-ready format.
You’ll learn:
- What each Linux directory means
- Why Linux treats everything as a file
- How paths and permissions work
- What’s important for system administration & cybersecurity
- Practical commands to explore the file system
- Real-world security relevance (priv esc, logs, malware persistence)
By the end, you will not only understand where things are stored — you will understand why the Linux filesystem is designed this way and how this knowledge directly helps in debugging, hacking, and securing systems.
SECTION 2 — What is a File System in Linux?
A file system in Linux is the method used by the operating system to store, organize, manage, and access data on storage devices such as HDDs, SSDs, USB drives, or even virtual cloud disks.
But Linux takes this concept much further than most operating systems…
2.1 Everything in Linux Is a File
The most fundamental principle in Linux:
“Everything is a file.”
This includes:
- Regular files
- Directories
- Hardware devices (e.g.,
/dev/sda,/dev/tty) - Running processes (
/proc/1234/) - Network sockets
- Pipes
- Kernel parameters
Linux abstracts all resources into the form of files, which simplifies management and interaction.
Example:
Typing
cat /proc/cpuinfo
prints CPU details — because Linux exposes hardware info as file content.
2.2 Role of a File System
A Linux file system decides:
- How data is stored
- How data is retrieved
- How free space is tracked
- How permissions are applied
- How fast read/write operations are performed
Different file systems have different strengths (speed, reliability, journaling, snapshots).
2.3 Common Linux File Systems
Here are the most widely used ones:
ext4 (Most common Linux filesystem)
- Fast
- Stable
- Journaling support
- Default on Ubuntu, Debian, Kali
XFS (High-performance)
- Used heavily in enterprise Linux (RHEL/CentOS)
- Great for large datasets & servers
Btrfs
-
Modern filesystem with:
- snapshots
- compression
- self-healing
-
Becoming popular on openSUSE, Fedora
Others
| File System | Usage |
|---|---|
| ext3 | older version of ext4 |
| FAT/exFAT | USB drives, dual booting |
| NTFS | Windows partitions, shared data |
| ZFS | advanced RAID, enterprise storage |
2.4 Why File Systems Matter
For a cybersecurity or Linux professional, understanding the filesystem allows you to:
Secure the OS
Knowing where logs, configs, binaries, and temp files live helps you audit, harden, and monitor systems.
Detect malware
Malware often hides in:
/tmp/var/tmp- cron jobs
- unauthorized scripts in
/etc
Perform digital forensics
Log analysis, file integrity checks, unauthorized file creation — all require filesystem understanding.
Perform privilege escalation
Misconfigured permissions on:
/etc/shadow/usr/bin/var/log
are common attack vectors.
2.5 The Root of Everything: “/”
All mounted devices, directories, and files exist under one global root directory:
/
This is the topmost level — the “starting point” for the entire filesystem tree.
Even if you add more storage, Linux mounts it somewhere under /.
SECTION 3 — Linux vs Windows File System (Clear & Practical Comparison)
Before diving into the Linux directory structure, it’s important to understand how Linux differs fundamentally from Windows.
This section gives readers instant clarity and removes confusion early in the blog.
3.1 Structural Difference: Drives vs Unified Tree
Windows:
Uses multiple drive letters:
C:\
D:\
E:\
Linux:
Everything lives inside a single hierarchical tree starting at:
/
There are no drive letters.
Even new disks/USB drives are mounted into this tree, usually under:
/mnt or /media
This unification makes Linux more predictable and modular.
3.2 Case Sensitivity
| Feature | Windows | Linux |
|---|---|---|
| Filename Case | Not case-sensitive | Case-sensitive |
| Example | File.txt = file.txt | File.txt ≠ file.txt |
This matters in scripts, web servers, and security (avoids ambiguity).
3.3 System Configuration Storage
Windows:
Uses a centralized registry:
HKEY_LOCAL_MACHINE
HKEY_CURRENT_USER
Linux:
Stores configuration in plain text files inside:
/etc
Examples:
/etc/passwd/etc/ssh/sshd_config/etc/fstab
This is why Linux is preferred in DevOps, servers, and hacking — everything is text-based, scriptable, and transparent.
3.4 Permissions & Security Model
Windows:
- File permissions exist but are complex (ACL-based)
- Administrator account is similar to Linux root
Linux:
- Simple permission model (
rwx) - Strong separation of users & processes
- Special permissions: SUID, SGID, Sticky Bit
- Least privilege by default
This strict model reduces the chances of system-wide compromise.
3.5 Program Installation Locations
Windows:
C:\Program Files
C:\Program Files (x86)
Linux:
Programs are installed across standardized directories:
| Directory | Purpose |
|---|---|
/bin | essential commands |
/usr/bin | user applications |
/usr/local/bin | custom-installed binaries |
This hierarchy allows cleaner package management and better separation of system vs user-installed software.
3.6 Key Philosophical Difference
Windows
GUI-first operating system
CLI is optional
Linux
CLI-first operating system
GUI is optional
This is why filesystem knowledge is essential in Linux.
3.7 Why Linux’s Approach Is Better for Security & Servers
- Transparent configuration (text files)
- Predictable folder structure
- Powerful permission & ownership system
- Logs stored in consistent locations
- Modular mounting system
- Easy automation & scripting
This makes Linux the top choice for:
- Cloud servers
- Web servers
- DevOps pipelines
- Cybersecurity labs
- CTF challenges
- Forensics investigations
SECTION 4 — Understanding the Root Directory /
The root directory, represented simply as /, is the topmost level of the Linux file system.
Every single file, directory, device, configuration, process, and mount point exists somewhere under this root.
Think of / as the tree trunk of the entire Linux system.
All other directories are branches growing out of it.
4.1 What Is / Exactly?
It is the parent directory of all directories.
Examples:
/home
/etc
/var
/usr
/dev
All start from /.
There is no folder above /.
It is the absolute starting point for:
- System booting
- Device mounting
- User directories
- System libraries
- Binary programs
- Configuration files
4.2 Why / Exists
The idea is simple:
To create a clean, predictable and unified directory structure for the entire system.
This avoids the confusion of multiple drives (like Windows C:\, D:\, E:\) and ensures:
- Easier automation
- Consistent paths
- Better portability
- Easier script execution
- Better permission control
4.3 What Lives Directly Under /?
When you run:
ls /
Typical directories you’ll see:
bin etc usr var home root tmp dev proc run opt mnt media lib
Each has a specific purpose according to the FHS (Filesystem Hierarchy Standard).
We’ll explain every one of these in the next section.
4.4 Only Root User Has Full Control of /
The superuser (root) is the only account with unrestricted permissions on /.
Normal users can only modify:
- Their home directory:
/home/username - Temporary directories they have access to (like
/tmp)
This strict separation prevents accidental or malicious system-wide damage.
4.5 / vs /root — Common Confusion
Many beginners confuse the two.
| Directory | Meaning |
|---|---|
/ | The root of the filesystem (top-level directory) |
/root | The home directory of the root (superuser) |
Example:
- Your normal user lives in
/home/satvik - The root user lives in
/root
4.6 / Is Always Mounted First
During boot, the kernel first mounts / from disk.
Only after / is ready can other directories or disks be mounted.
This is why / contains:
- Essential binaries (
/bin,/sbin) - Essential libraries (
/lib) - Kernel info folders (
/proc,/sys) - Device files (
/dev)
4.7 Why Understanding / Matters
For cybersecurity, DevOps, or Linux troubleshooting:
✔ Knowing what / contains helps detect unauthorized files
✔ Privilege escalation usually involves modifying key directories under /
✔ Malware often hides in /etc, /usr, or /var/tmp
✔ Forensics relies on tracing artifacts in /var, /proc, /root, etc.
✔ Server debugging of logs happens under /var/log, which comes from /
Understanding / is the foundation for everything else in the Linux OS.
SECTION 5 — The Linux Directory Structure Explained (FHS Standard)
This is the most important and detailed section of the blog.
Here we break down every major directory under /, explain its purpose, what you’ll find inside, and its relevance for administration, development, and cybersecurity.
5.1 /bin — Essential User Commands
Purpose:
Stores essential user commands needed for system booting and basic day-to-day tasks.
Examples:
ls, cp, mv, cat, grep, echo, pwd, touch
When is /bin used?
- System boot (before
/usris mounted) - Recovery mode
- Single-user mode
Cybersecurity Note:
If an attacker replaces binaries in /bin, the entire system is compromised.
5.2 /sbin — System Administration Binaries
Purpose:
Contains system-level tools intended for root or administrative tasks.
Examples:
mount, umount, fsck, iptables, shutdown
Used for:
- Filesystem repair
- Network configuration
- System boot & shutdown
Security Relevance:
Privilege escalation attacks often target writable paths or misconfigurations involving /sbin.
5.3 /etc — Configuration Files
Purpose:
The brain of the Linux system — stores configuration for almost everything.
Examples inside /etc:
passwd → user accounts
shadow → password hashes
ssh/sshd_config → SSH server configuration
fstab → disk mount settings
crontab → scheduled tasks
Cybersecurity Relevance:
- Misconfiguration here = immediate attack surface
- Attackers target
/etc/shadow,/etc/ssh,/etc/cron* - Forensics checks
/etcfor unauthorized changes
5.4 /home — User Home Directories
Each user gets a separate space:
/home/satvik
/home/rahul
/home/admin
Contains:
- Desktop files
- Documents
- Configs (
.bashrc,.ssh/) - User-specific application data
Security Note:
SSH keys are commonly stored in:
~/.ssh/id_rsa
5.5 /root — Root User’s Home Directory
Not to be confused with /.
Purpose:
Home for the superuser.
Why it's separate from /home?
- For security
/homemay be on a separate partition;/rootmust always be available.
Contains:
- Sensitive scripts
- Admin keys
- System-level configs
This directory must be protected strictly.
5.6 /var — Variable Data (Logs, Queues, DBs)
This directory changes frequently.
Contains:
/var/log → system & service logs
/var/www → web server files
/var/mail → mailbox storage
/var/lib → databases, package data
/var/spool → print/mail queues
Why important?
-
Most important directory for incident response
-
Logs needed for forensics:
/var/log/auth.log/var/log/syslog/var/log/nginx/access.log
Attackers Often Target /var:
- Log wiping
- Persistence mechanisms
- Web shells in
/var/www/html
5.7 /usr — User Applications & Utilities
The largest directory in most Linux systems.
Contains:
/usr/bin → user commands
/usr/sbin → admin commands
/usr/lib → libraries
/usr/share → shared data
/usr/local → user-compiled programs
Think of it like:
Program Files in Windows — but better organized.
Cybersecurity Note:
If /usr gets corrupted, many applications break.
5.8 /tmp — Temporary Files
Purpose:
Stores temporary files created by applications.
Key Facts:
- World-writable (any user can write here)
- Automatically cleared on reboot
- Programs often place temporary runtime files here
Security Danger:
Very commonly exploited for:
- Privilege escalation
- Dropping malicious scripts
- Running temporary payloads
Why? Because /tmp is always writable.
5.9 /dev — Device Files
Linux treats hardware as files.
Examples:
/dev/sda → Hard drive
/dev/tty → Terminal
/dev/null → "Black hole" file
/dev/zero → Stream of zero bytes
Why this matters?
- Tools like
fdisk,mount,ddinteract with/dev - Forensics tools read devices through
/dev
5.10 /proc — Virtual Filesystem for Processes
A dynamic, in-memory filesystem — not stored on disk.
Examples:
/proc/cpuinfo
/proc/meminfo
/proc/uptime
/proc/1234/ → details of process with PID 1234
Why this exists:
To expose kernel and process info as text files.
Used for:
- Performance monitoring
- Forensics
- Debugging
- Malware analysis (process inspection)
5.11 /sys — Kernel & Device Information
Similar to /proc, but focused on hardware and kernel interfaces.
Used for:
- Driver information
- Device events
- Kernel parameters (modifiable via sysfs)
5.12 /mnt — Temporary Mount Directory
Used by admins to manually mount external drives.
Example:
mount /dev/sdb1 /mnt
5.13 /media — Removable Media Mount Point
Automatically used for:
USB drives
DVDs
SD cards
5.14 /opt — Optional / Third-Party Software
Used for:
Chrome
VirtualBox
Custom apps
Usually large self-contained software lives here.
5.15 /lib and /lib64 — System Libraries
Contains essential libraries needed by binaries in /bin and /sbin.
Example:
libc.so
ld-linux.so
If this directory breaks → system becomes unbootable.
5.16 /run — Runtime Data (PID Files, Sockets)
Stores:
/run/sshd.pid
/run/docker.sock
/run/systemd/
These are recreated every boot.
This completes the full Linux Directory Hierarchy section.
SECTION 6 — File Types in Linux
In Linux, not all “files” are traditional text or binary documents.
Because Linux treats everything as a file, the system uses different file types to represent objects like devices, directories, processes, and communication channels.
Understanding file types is essential for system administration, forensics, privilege escalation, and debugging.
6.1 How to Identify File Types
When you run:
ls -l
You’ll see something like:
drwxr-xr-x 2 root root 4096 Jan 1 /home
-rw-r--r-- 1 root root 1024 Jan 1 file.txt
lrwxrwxrwx 1 root root 12 Jan 1 link -> /etc/passwd
The first character tells you the file type:
| Symbol | Type |
|---|---|
- | Regular file |
d | Directory |
l | Symbolic link |
c | Character device |
b | Block device |
s | Socket |
p | Named pipe (FIFO) |
Let’s break down each one.
6.2 Regular File (-)
A standard file used for:
- Text documents
- Scripts
- Binaries
- Logs
- Images
- Config files
Examples:
/etc/passwd
/home/user/script.py
6.3 Directory (d)
A folder that stores other files.
Examples:
/home
/etc
/usr
Directories have execute (x) permissions to allow entering them.
6.4 Symbolic Link (l)
A shortcut or pointer to another file.
Example:
/bin/sh -> /usr/bin/bash
Useful for:
- Compatibility
- Changing default interpreters
- Managing versions of software
Cybersecurity Note:
Attackers sometimes replace symlinks to redirect execution.
6.5 Character Device (c)
Represents a device that sends/receives data one character at a time.
Examples:
/dev/tty (terminal)
/dev/random (random number generator)
Used for:
- Serial communication
- Keyboard & mouse input
- Terminal access
6.6 Block Device (b)
These handle data in blocks (faster, buffered).
Examples:
/dev/sda (hard disk)
/dev/nvme0n1
Used by:
- Filesystems
- Partitions
- Disk utilities (
fsck,fdisk,mount)
6.7 Named Pipe / FIFO (p)
Allows inter-process communication.
Example:
mkfifo mypipe
Used when one program outputs data and another reads it.
6.8 Socket (s)
Used for network-style IPC communication.
Examples:
/run/docker.sock
/var/run/mysqld/mysqld.sock
Sockets allow:
- Local communication
- Database connections
- Container engines
6.9 Why File Types Matter in Security
Understanding file types is critical in:
Malware detection
Attackers often drop payloads into:
- sockets
- pipes
- symlinks
- temp files
Privilege escalation
Writable device files or symlink misconfigurations often lead to root access.
Forensics
Investigators review:
- suspicious device nodes
- runtime sockets
- unexpected symlinks pointing to sensitive files
System hardening
Ensuring only necessary types exist in critical directories (/bin, /etc, /usr/bin).
This section gives readers a clear understanding of how Linux represents every object.
SECTION 7 — Absolute vs Relative Paths
Understanding paths is essential for navigating the Linux file system efficiently.
Whether you're writing scripts, performing penetration testing, managing servers, or troubleshooting, path accuracy is critical.
This section removes confusion and makes the concept crystal clear.
7.1 What Is a Path in Linux?
A path is simply the location of a file or directory in the filesystem.
Linux supports two types of paths:
- Absolute Path
- Relative Path
Let’s explore both.
7.2 Absolute Path
An absolute path always starts from the root directory / and provides the complete location of a file or folder.
Characteristics:
- Begins with
/ - Always unique
- Does not depend on the current working directory
Examples:
/home/satvik/Documents/report.txt
/etc/ssh/sshd_config
/var/log/syslog
/bin/bash
Why absolute paths are important:
✔ Useful in scripts to avoid ambiguity
✔ System services depend on absolute paths
✔ Reliable for cron jobs, automation, and system-level tasks
7.3 Relative Path
A relative path is based on your current working directory.
Characteristics:
- Does not start with
/ - Shorter to type
- Depends on where you currently are
Examples:
If you are inside:
/home/satvik
Then:
cd Documents
is a relative path that moves to:
/home/satvik/Documents
7.4 Special Relative Path Symbols
. (dot) → current directory
Example:
./script.sh
Runs a script in the current folder.
.. (double dot) → parent directory
Example:
cd ..
Moves up one directory.
Examples combining both:
cd ../Downloads
cd ./folder/subfolder
7.5 Practical Examples
Example 1: Navigating with absolute path
cd /etc/nginx
No matter where you are, this goes to the Nginx directory.
Example 2: Navigating with relative path
Suppose you are in:
/etc
Then:
cd nginx
uses a relative path to enter /etc/nginx.
Example 3: Going up directories
cd ../../
Moves up two levels.
Example 4: Running a program in the current directory
./program
Without ./, Linux won’t look in the current directory for execution.
7.6 Why Linux Uses Both Path Types
Flexibility
Relative paths save time when navigating within a directory tree.
Reliability
Absolute paths avoid mistakes in automation, scripts, and cron jobs.
Security
Poorly specified paths in scripts can be exploited for privilege escalation:
Example vulnerability:
If a script runs something like:
cp file /usr/bin
instead of:
cp /home/user/file /usr/bin
an attacker could replace file in the current directory.
7.7 Key Tip to Remember
If you're writing a script, ALWAYS use absolute paths.
If you're manually navigating, relative paths are usually faster.
SECTION 8 — Linux File Permissions (r, w, x) Explained Clearly*
Linux permissions are one of the most powerful and important security features of the operating system.
They determine who can read, write, or execute a file, and this directly affects system security, process behavior, and privilege escalation vectors.
In this section, we break down permissions in the simplest and most practical way.
8.1 Why Permissions Exist
Linux is a multi-user operating system.
Permissions prevent one user from:
- Reading another user’s files
- Modifying critical system files
- Executing unauthorized programs
This isolation is the foundation of Linux security.
8.2 Permission Structure Overview
Run:
ls -l
Example output:
-rwxr-xr-- 1 root root 4096 script.sh
Breakdown:
- rwx r-x r--
│ │ │ │
│ │ │ └─ others permissions
│ │ └────── group permissions
│ └──────────── owner permissions
└──────────────── file type
File type:
-→ regular filed→ directoryl→ symlink
(covered in previous section)
Permissions:
| Letter | Meaning |
|---|---|
| r | read |
| w | write |
| x | execute |
8.3 The Three Permission Groups
- User (owner)
- Group
- Others (everyone else)
Using:
-rwxr-xr--
Owner (User)
rwx
Owner can read, write, execute.
Group
r-x
Group can read, execute but not write.
Others
r--
Others can only read.
8.4 Changing Permissions Using chmod
Symbolic Mode
chmod u+x file → add execute for user
chmod g-w file → remove write for group
chmod o+r file → add read for others
chmod a-x file → remove execute for everyone
Numeric (Octal) Mode
| Permission | Value |
|---|---|
| r | 4 |
| w | 2 |
| x | 1 |
Examples:
chmod 755 file → rwx r-x r-x
chmod 644 file → rw- r-- r--
chmod 700 file → rwx --- ---
chmod 600 file → rw- --- ---
chmod 777 file → rwx rwx rwx (dangerous!)
8.5 Changing Ownership Using chown and chgrp
Change owner:
chown user file
Change group:
chgrp developers file
Change owner and group together:
chown root:root file
8.6 Special Case: Directories and Execute Bit
For directories:
| Permission | Meaning |
|---|---|
| r | List files (ls) |
| w | Create/delete files |
| x | Enter directory (cd) |
Example:
A directory without x cannot be entered even if r is set.
8.7 Common Real-World Configurations
1. Web server directories:
/var/www/html → 755 or 750
2. SSH private key:
~/.ssh/id_rsa → 600
3. User home directory:
/home/user → 700
4. Scripts intended for execution:
chmod +x script.sh
8.8 Security Risks Due to Wrong Permissions
World writable directories
e.g., /tmp, /var/tmp
Attackers use them to:
- Drop payloads
- Execute scripts
- Replace symlinks
Writable system files
Incorrect permissions on:
/etc/passwd
/etc/shadow
/usr/bin
lead to immediate privilege escalation.
777 permissions
Never use chmod 777 unless absolutely required (rare).
8.9 Quick Permission Cheat Sheet
644 → Files readable by all; writable only by owner
600 → Private confidential files (SSH keys)
755 → Programs/scripts everyone can run but not modify
700 → Private directories
777 → Avoid completely unless temporary
This section makes permissions very clear, practical, and security-focused.
SECTION 9 — Special Permissions: SUID, SGID, and Sticky Bit
Beyond regular permissions (r, w, x), Linux includes three special permission bits that control how certain files and directories behave.
These are critical for system administration, privilege escalation understanding, and securing Linux servers.
Let’s break them down simply and clearly.
9.1 Why Special Permissions Exist
Some programs need temporary elevated privileges to do their job.
Example:
Any user should be able to change their password, right?
But the password file /etc/shadow is only writable by root.
Solution?
The passwd command runs with root permissions temporarily, thanks to SUID.
These special bits exist to enable controlled privilege elevation without giving full root access.
9.2 SUID — Set User ID
Symbol: s in the user permission section
Numeric value: 4 (used in chmod like chmod 4755 file)
What SUID Does:
When a file with SUID is executed, it runs with the owner's permissions, not the user who launched it.
Example: /usr/bin/passwd
-rwsr-xr-x 1 root root 54256 /usr/bin/passwd
Notice the s in place of x for the user:
rws
This means:
- Normal users can execute it
- It executes as root
Use Case:
Allows users to:
- Change passwords
- Access secure resources temporarily
- Run system utilities safely
Security Risk:
If a program with SUID is vulnerable:
- Attackers may escalate to root
- Many CTFs and real-world exploits target SUID binaries
9.3 SGID — Set Group ID
Symbol: s in the group permission section
Numeric value: 2 (used like chmod 2755 dir)
What SGID Does On Files:
When executed, the program runs with the group’s privileges.
What SGID Does On Directories:
All new files and folders created inside inherit the group ownership of the directory.
Use Case:
Helpful for shared folders like:
/var/www
/home/groups/project/
Security Benefit:
Enforces controlled collaboration.
Security Risk:
- Wrong SGID settings can expose files
- Attackers can abuse group privileges to escalate
9.4 Sticky Bit — Restricted Deletion Flag
Symbol: t
Numeric value: 1 (used like chmod 1777 dir)
What Sticky Bit Does:
Users can create files, but cannot delete files created by others.
Common Example: /tmp
drwxrwxrwt 9 root root 4096 /tmp
Notice the t at the end:
rwt
Why /tmp Needs Sticky Bit:
Without it:
- Any user could delete another user’s files
- Major security risk
Use Case:
Used on world-writable directories such as:
/tmp
/var/tmp
9.5 Numeric Representation
Special permissions are added before the usual 3-digit permissions.
| Special Bit | Value |
|---|---|
| SUID | 4 |
| SGID | 2 |
| Sticky Bit | 1 |
Examples:
chmod 4755 file → SUID + 755
chmod 2755 dir → SGID + 755
chmod 1777 /tmp → Sticky + 777
9.6 Security Relevance (Very Important for Cybersecurity)
Privilege Escalation
Misconfigured SUID binaries are one of the top privilege escalation vectors.
Example:
find, vim, nmap, python
If accidentally given SUID → instant root.
Persistence
Attackers may modify or replace SUID binaries to maintain access.
Forensics
Investigators always check:
find / -perm -4000 -type f 2>/dev/null
To detect suspicious SUID files.
Hardening
Admins should regularly audit system permissions.
9.7 Cheat-Sheet Summary
| Bit | Symbol | Meaning | Typical Locations |
|---|---|---|---|
| SUID | s | Run as file owner | /usr/bin/passwd |
| SGID | s | Run as file’s group / Inherit group | shared directories |
| Sticky Bit | t | Only owner can delete files | /tmp, /var/tmp |
These three bits protect the system when used correctly and break it when misconfigured.
SECTION 10 — Mounting & Partitions in Linux
Linux does not assign drive letters like Windows (C:, D:).
Instead, Linux mounts storage devices into the single global directory tree starting at /.
This section explains mounting, partitions, filesystems, and their real-world significance in servers, DevOps, and cybersecurity.
10.1 What Is a Partition?
A partition is a logically divided section of a physical disk.
Example disk:
/dev/sda
Example partitions:
/dev/sda1
/dev/sda2
/dev/sda3
Each partition can hold:
- A filesystem (ext4, XFS, etc.)
- A swap area
- Bootloader data
Partitions allow:
✔ OS separation
✔ Recovery
✔ Performance optimization
✔ Better backup granularity
10.2 What Is Mounting?
Mounting means attaching a filesystem to a directory in the Linux tree.
Example:
mount /dev/sdb1 /mnt
Meaning:
"You can now access the contents of the disk /dev/sdb1 through the folder /mnt."
After mounting:
/mnt/files
/mnt/documents
Represent the files actually stored in the partition.
10.3 Common Mount Points
| Mount Point | Purpose |
|---|---|
/mnt | Temporary/manual mounts |
/media | Auto-mounted USB drives, external disks |
/boot | Bootloader files |
/home | User data partition |
/var | Logs, DBs, servers (common to mount on separate disk) |
/ | Root filesystem |
Servers often mount /var and /home separately for performance and security.
10.4 Checking Mounted Filesystems
Run:
df -h
Example output:
/dev/sda1 50G mounted on /
/dev/sdb1 200G mounted on /var
/dev/sdc1 100G mounted on /home
Meaning:
/is on one disk/var(logs, DBs) on another/homeon another
This separation prevents one directory from consuming all disk space.
10.5 Viewing Block Devices
Run:
lsblk
Output:
sda
├─ sda1 /
├─ sda2 /boot
sdb
├─ sdb1 /var
sdc
├─ sdc1 /home
This visually shows which device is mounted where.
10.6 Auto-Mounting with /etc/fstab
Linux uses the file:
/etc/fstab
to determine which partitions should be automatically mounted at boot.
Example entry:
/dev/sdb1 /var ext4 defaults 0 2
Meaning:
- Device:
/dev/sdb1 - Mount point:
/var - Filesystem:
ext4 - Auto-mount at boot
Mistakes in fstab can prevent system boot.
This is why DevOps engineers treat fstab carefully.
10.7 Temporary Mounts (Manual)
To mount manually:
mount /dev/sdb1 /mnt
To unmount:
umount /mnt
(Careful: it’s umount, not "unmount")
10.8 Swap Partitions
Swap is a dedicated partition or file used when RAM is full.
Check swap:
swapon --show
Swap allows:
- Temporary memory spillover
- Hibernation
- Better stability
Servers use swap carefully — too much swap = slow performance.
10.9 Why Mounting Matters in Cybersecurity
1. Hidden Malware on External Drives
Attackers may mount devices manually to hide payloads.
2. Forensics: Disk Imaging
Tools like dd, autopsy, sleuthkit use mounted block devices for analysis.
3. Misconfigured Permissions on Mounted FS
If a partition is mounted with exec, noexec, nosuid, etc., it affects attacks.
Example:
Mounting /tmp as:
/tmp ext4 defaults,noexec,nosuid
Prevents:
- Script execution
- SUID binaries
- Easy malware deployment
4. Docker, Kubernetes, Cloud Storage
All rely heavily on mount namespaces and overlay filesystems.
10.10 Mount Options (Security-Related)
IMPORTANT for security hardening:
| Option | Meaning |
|---|---|
noexec | Prevent execution of binaries |
nosuid | Disable SUID binaries |
nodev | Prevent device files |
ro | Read-only |
Example:
/tmp ext4 defaults,noexec,nosuid,nodev 0 2
This blocks common privilege escalation vectors.
10.11 Summary of Mounting & Partitions
- Linux mounts devices into directories, no drive letters
- Partitions allow better security & organization
/etc/fstabcontrols auto-mountinglsblk,df -hhelp visualize mounts- Mount options significantly affect security
- Critical in forensics, hacking, cloud, and DevOps
SECTION 11 — Why the Linux File System Matters in Cybersecurity
Understanding the Linux file system is not just useful — it is mandatory for anyone in cybersecurity, penetration testing, SOC, incident response, or digital forensics.
Nearly every attack technique, log trail, privilege escalation vector, and forensic artifact is connected directly to different parts of the Linux filesystem.
This section explains exactly why.
11.1 Privilege Escalation Depends on File System Knowledge
Most Linux privilege escalation techniques come from:
Misconfigured permissions
Examples:
SUID binaries in /usr/bin
Writable scripts in /etc/init.d
World-writable directories like /var/tmp
Weak file permissions on sensitive files
If /etc/shadow, /etc/passwd, or /etc/sudoers are writable → instant root.
PATH hijacking
If /usr/local/bin or /tmp come earlier in $PATH, attackers can place malicious executables.
SUID exploitation
Attackers search for:
find / -perm -4000 -type f 2>/dev/null
Files like:
/usr/bin/python
/usr/bin/nmap
/usr/bin/bash
should never have SUID — but misconfigurations happen.
11.2 Log Analysis for Incident Response Lives in /var/log
All major forensic data is stored under:
/var/log
Examples:
auth.log→ authentication attemptssyslog→ general system activitydmesg→ kernel eventsapache2/access.log→ web attackssecure→ failed logins (CentOS/RHEL)
Typical attack traces found here:
- Brute force attempts
- Unauthorized privilege escalations
- Cron persistence
- Malware execution logs
- Deleted user traces
Understanding the structure of /var is mandatory for IR/SOC.
11.3 Malware Persistence Often Targets These Directories
Attackers place persistence mechanisms in:
| Directory | Why Targeted |
|---|---|
/etc/cron* | Scheduled malicious jobs |
/etc/rc.local | Startup scripts |
/etc/systemd/system/ | Fake system services |
/tmp & /var/tmp | Writable by everyone |
/usr/local/bin | Poisoning commands |
/home/*/.ssh/ | Backdoor SSH keys |
/opt | Hide malicious apps |
A SOC analyst must know where to look.
11.4 Misconfigurations in /etc Lead to Immediate Vulnerabilities
Examples:
Wrong SSH configuration
File:
/etc/ssh/sshd_config
Misconfig:
PermitRootLogin yes
PasswordAuthentication yes
→ Immediate brute-force target.
Weak sudo rules
File:
/etc/sudoers
Misconfig:
user ALL=(ALL) NOPASSWD: ALL
→ User becomes root without password.
11.5 Web Server Attacks Directly Involve the Filesystem
For Apache:
/var/www/html
/etc/apache2/
For Nginx:
/etc/nginx/
var/log/nginx/
Attackers place web shells in:
/var/www/html/uploads
Tools like:
- Weevely
- China Chopper
- PHP web shells
all depend on filesystem permissions to execute.
11.6 Forensics Investigations = File System Traversal
IR teams examine:
/home→ user activity/root→ root-level actions/var/log→ system traces/proc→ running process artifacts/tmp→ temporary malware/etc→ modified configs/usr/bin→ replaced binaries
Every clue is inside the filesystem.
11.7 Reverse Shells & Payloads Need Writable Paths
Attackers frequently write payloads to:
/tmp
/var/tmp
/dev/shm
Because they are:
- World writable
- Usually executable
- Not monitored strictly
Mitigation:
Mount them with:
noexec, nosuid, nodev
11.8 For Pentesters: Knowing Directories Speeds Up Enumeration
Tools look for:
/etc/passwd
/etc/shadow
/etc/hosts
/home/*/.ssh/
/var/log/*
/proc/version
/proc/self/environ
You know exactly where valuable data lives.
11.9 File System Hardening is a Core Blue Team Skill
Admins secure systems by:
- Setting strict permissions on
/etc/,/usr/,/var/ - Using mount options (
noexec,nosuid,nodev) - Auditing SUID binaries
- Enforcing least privilege in home directories
- Restricting logs and sensitive files
11.10 Summary
The Linux filesystem is one of the biggest influencers in cyber operations because:
- Security breaks when permissions break
- Forensics relies completely on files
- Privilege escalation abuses file locations
- Attackers hide malicious files in predictable directories
- Logs, configs, services — everything lives inside the filesystem
Understanding it deeply gives you a huge edge in both offense and defense.
SECTION 12 — Practical Commands to Explore the Linux File System
This section gives readers a hands-on understanding of how to navigate, inspect, audit, and analyze the Linux file system using essential commands.
These commands are valuable for beginners, sysadmins, pentesters, and SOC analysts.
12.1 Basic Navigation Commands
Show current directory
pwd
List files
ls
ls -l → long format
ls -la → include hidden files
ls -lh → human-readable sizes
ls -R → recursive listing
Change directory
cd /etc
cd /home/satvik
cd ..
cd -
12.2 Viewing File Content
Basic commands
cat file.txt
head file.txt
tail file.txt
View file with line numbers
nl file.txt
Follow file in real time (very useful for logs)
tail -f /var/log/auth.log
12.3 Exploring Directory Structure
Show directory tree
tree /
(Install via sudo apt install tree)
Disk usage summary
du -sh *
du -sh /var/*
Storage overview
df -h
12.4 Searching Files & Directories
Search by name
find /etc -name "*.conf"
find / -type f -name shadow 2>/dev/null
Search by permission
find / -perm -4000 2>/dev/null → SUID files
find / -perm -2000 2>/dev/null → SGID files
find / -perm -777 2>/dev/null → world-writable
Search by size
find /var -size +100M
12.5 Viewing System & Kernel Info
CPU Info
cat /proc/cpuinfo
Memory Info
cat /proc/meminfo
Running processes
ps aux
Kernel version
cat /proc/version
uname -a
12.6 Working with Mounts & Devices
Show block devices
lsblk
Show mounted filesystems
mount | column -t
df -Th
Manually mount a device
mount /dev/sdb1 /mnt
Unmount
umount /mnt
12.7 Checking Permissions
View file permissions
ls -l file
Change permissions
chmod 755 file
chmod 600 ~/.ssh/id_rsa
Change owner
chown root:root file
Detect dangerous permissions
find / -perm -0002 -type d 2>/dev/null → world-writable directories
12.8 Commands Useful in Pentesting / Forensics
Find SUID binaries
find / -perm -4000 2>/dev/null
Find recently modified files
find / -mtime -1
Find files with capabilities
getcap -r / 2>/dev/null
Check cron jobs
ls -l /etc/cron*
crontab -l
Check network sockets
ss -tulnp
Show environmental variables
cat /proc/self/environ
12.9 Cleaning Temporary Directories
Useful for security and maintenance:
rm -rf /tmp/*
rm -rf /var/tmp/*
(Use with caution!)
12.10 Quick Reference Table
| Task | Command |
|---|---|
| Explore FS | lsblk, df -h, du -sh |
| Search files | find, grep |
| Permissions | chmod, chown, ls -l |
| Logs | tail -f /var/log/auth.log |
| System info | uname, /proc/* |
| Priv esc hunting | find / -perm -4000 |
| Mount info | mount, /etc/fstab |
This section equips the reader with the practical tools to explore any Linux system effectively.
SECTION 13 — Conclusion
The Linux file system may seem overwhelming when you first look at it — dozens of directories, strange names, strict permissions, and a completely different structure from Windows.
But once you understand the logic behind it, Linux becomes predictable, powerful, elegant, and secure.
In this blog, you learned:
The philosophy behind the Linux filesystem
Everything is a file → a simple but powerful abstraction.
How Linux organizes all data under a single root /
A unified directory tree makes automation, scripting, and administration clean and consistent.
The purpose of each major directory
From /etc for configuration to /var for logs and /home for user data — you now understand exactly where things live and why.
How permissions and special bits work
rwx, SUID, SGID, Sticky Bit — the core of Linux security and privilege management.
Mounting, partitions, devices, and filesystem types
Critical concepts for cloud servers, DevOps, cybersecurity labs, and forensics.
Why the Linux filesystem is essential for security
Almost every attack, investigation, privilege escalation attempt, and malware trace relies on filesystem knowledge.
Practical commands every professional needs
From navigation to enumeration, this gives you real hands-on capability.
Final Thought
Mastering the Linux filesystem is not just about knowing directories.
It’s about understanding how Linux thinks.
When you understand the file system:
- Troubleshooting becomes effortless
- Pentesting becomes faster
- Forensics becomes accurate
- DevOps tasks become intuitive
- System security becomes stronger
This is one of the core foundations that separates beginners from professionals.
Enjoyed this report?
If it helped, like it and pass it on to someone who needs it.
cybersecurityFeaturedDiwali Lights and Cyber Fights: How the Festival of Lights Teaches Us Digital Defense
Light up Diwali 2025 with more than just diyas! As a B.Tech cybersecurity geek, I see the Festival of Lights as a cyber-defense playbook. From dodging phishing scams (Ravana’s digital disguises) to securing your e-wallet like Lakshmi’s treasure, this blog blends festive vibes with smart tips. Learn how rangoli mirrors multi-factor authentication and firecrackers warn against risky apps. With festive scams spiking 40%, let’s make Diwali hack-proof! Celebrate with sweets, sparkles, and digital shields your guide to a safe, joyous Diwali awaits! #DiwaliCybersecurity #FestiveTechTips
How Websites Work TryHackMe Walkthrough (All Answers)
All five tasks of TryHackMe's How Websites Work room, answered: HTML, JavaScript, sensitive data hidden in page source, and HTML injection with a malicious link.
WebDNS in Detail
The DNS in Detail TryHackMe room is your crash course in the Domain Name System (DNS), the internet’s address book that turns domain names (like google.com) into IP addresses. You’ll learn how DNS resolves names to IPs, the domain hierarchy (like TLDs and subdomains), and record types (A, AAAA, MX, CNAME, TXT). Tasks include querying DNS records using a simulated tool, answering questions like “What’s the CNAME of shop.website.thm?” (Answer: shops.myshopify.com). You’ll also explore rules, like subdomains being limited to 63 characters and not allowing underscores. Real-world example: In 2023, attackers used DNS tunneling to exfiltrate data from compromised networks, showing why understanding DNS is key for SOC analysts. This room’s hands-on exercises, like sending DNS requests, make it a great primer for networking and cybersecurity.
Part of the Series
cybersecurity simplifiedThe Secret Campus of Connections: A Beginner's Guide to Ports and Protocols in Networking
5 min read
Quantum Chaos: When the Future of Computing Meets the Fragility of Cybersecurity
10 min read
OTP or Chill? A Gen-Z Guide to Streaming, Sharing, and Staying Secure
10 min read
Red Teaming vs. Pentesting: Are You Really Secure?
4 min read
OWASP Top 10 2025: The 10 Deadly Web Traps Even Your Grandma Could Fall Into (And How to Escape Them)
5 Min
How Supply Chain Vulnerabilities in Cybersecurity Can Sneak Up on You
5 min read
Mastering the Linux File System: Structure, Permissions & Security — A Complete Beginner-to-Advanced Guide
10 min read