Master the Linux file system hierarchy, navigation commands, and essential directory structures for penetration testing. Learn cd, ls, pwd, find commands and understand critical directories l
A definitive, hands-on 2026 security audit guide for GraphQL APIs: covering schema discovery, introspection analysis, authorization auditing (BOLA/BFLA), query complexity DoS prevention, and
25 min read
A comprehensive first-principles guide to assessing and securing web APIs in 2026, covering OWASP API Top 10, BOLA testing, JWT security, GraphQL audits, and FastAPI/Next.js defensive remedia
Understanding the Linux file system is fundamental for any aspiring penetration tester or ethical hacker. Unlike Windows with its drive letters (C:, D:), Linux uses a hierarchical tree structure where everything stems from a single root directory. This comprehensive guide will teach you how to navigate, understand, and leverage the Linux file system for penetration testing operations.
Whether you're just starting with Kali Linux installation or preparing for professional penetration testing engagements, mastering file system navigation is your gateway to becoming proficient in Linux-based security operations.
/In Linux, everything is a file - this philosophical approach extends to devices, sockets, and directories. The entire file system begins at the root directory denoted by a single forward slash /. Unlike Windows, there are no separate drive letters; all storage devices and partitions are mounted as branches of this single tree.
# View the root directory
ls /
This simple command reveals the top-level directories that form the foundation of your Linux system.
/root - The Superuser's HomeThe /root directory is the home directory for the root user (system administrator with ultimate privileges). This is distinct from the root directory /.
# Access root's home (requires root privileges)
sudo ls /root
# Check your current user's home
echo $HOME
Why it matters for pentesters:
/root.bash_history often reveals administrative commands/home - User Home DirectoriesEvery regular user gets a dedicated directory under /home/username. This is where personal files, configurations, and user-specific data reside.
# List all user home directories
ls -la /home/
# View your home directory
cd ~
pwd
Pentesting significance:
~/.ssh/)/etc - Configuration CentralThe /etc directory contains system-wide configuration files. This is one of the most critical directories for security professionals.
# View configuration files
ls /etc/
# Critical files for pentesters
cat /etc/passwd # User account information
sudo cat /etc/shadow # Password hashes (requires root)
cat /etc/hosts # Hostname to IP mappings
cat /etc/resolv.conf # DNS configuration
Essential /etc files for ethical hackers:
/etc/passwd: Contains user account information (usernames, UIDs, home directories)/etc/shadow: Stores encrypted password hashes (accessible only by root)/etc/group: Group membership information/etc/sudoers: Sudo privileges configuration/etc/crontab: Scheduled task definitions (useful for persistence)/etc/ssh/sshd_config: SSH server configuration/etc/network/interfaces: Network interface configuration (Debian-based)/var - Variable DataThe /var directory holds variable data that changes during system operation - logs, databases, mail spools, and temporary files.
# Navigate to logs
cd /var/log/
ls -lh
# View recent authentication attempts
sudo tail -f /var/log/auth.log # Debian/Ubuntu
sudo tail -f /var/log/secure # CentOS/RHEL
Key subdirectories for pentesters:
/var/log/: System and application logs
auth.log / secure: Authentication attemptssyslog / messages: General system messagesapache2/ or nginx/: Web server logsmysql/: Database logs/var/www/: Web server document root (often)/var/spool/cron/: User cron jobs/var/backups/: System backups (may contain sensitive data)/tmp - Temporary File StorageThe /tmp directory is world-writable and used for temporary file storage. Files here may be deleted on reboot.
# Create a temporary file
echo "test" > /tmp/myfile.txt
# Check permissions
ls -ld /tmp
# Output: drwxrwxrwt (note the 't' - sticky bit)
Security implications:
noexec to prevent execution (check with mount | grep tmp)/dev/shm (RAM-based temporary storage, often not monitored)/usr - User Binaries and DataDespite its name, /usr (Unix System Resources) contains user-accessible applications, libraries, and documentation - not user data.
# Common usr subdirectories
ls /usr/bin/ # User commands
ls /usr/sbin/ # System administration commands
ls /usr/local/ # Locally installed software
ls /usr/share/ # Architecture-independent data
Structure:
/usr/bin/: Essential command binaries (ls, cat, grep)/usr/sbin/: System binaries (usually require root)/usr/local/bin/: Locally compiled/installed programs/usr/share/: Documentation, icons, man pages/opt - Optional/Third-Party SoftwareThe /opt directory houses add-on application packages - particularly third-party and larger software suites.
# View installed optional software
ls /opt/
# Common in Kali Linux
ls /opt/ | grep -E "metasploit|burp|maltego"
Pentesting tools often found here:
/bin and /sbin - Essential Binaries/bin: Contains essential command-line utilities needed for system booting and repair (bash, ls, cat, cp, mv)/sbin: System binaries for system administration (fsck, reboot, iptables, ifconfig)# View essential commands
ls /bin/ | head -20
# View system administration tools
ls /sbin/ | head -20
Note: Modern distributions often symlink /bin to /usr/bin and /sbin to /usr/sbin for consistency.
/dev - Device FilesLinux represents hardware devices as files in /dev. This includes hard drives, terminals, USB devices, and pseudo-devices.
# List device files
ls /dev/
# View disk devices
ls /dev/sd* # SATA/SCSI disks
ls /dev/nvme* # NVMe drives
# Special devices
cat /dev/urandom | head -c 16 # Random data generator
echo "test" > /dev/null # Null device (discards data)
Important devices:
/dev/sda, /dev/sdb: Hard drives/dev/tty: Terminal devices/dev/null: Discards all written data/dev/zero: Provides null bytes/dev/random, /dev/urandom: Random number generators/proc and /sys - Virtual File SystemsThese aren't real file systems but interfaces to kernel data structures.
# View running processes
ls /proc/ # Each number is a process ID (PID)
# System information
cat /proc/cpuinfo # CPU details
cat /proc/meminfo # Memory information
cat /proc/version # Kernel version
cat /proc/net/tcp # Active TCP connections
# Hardware information
ls /sys/class/net/ # Network interfaces
Pentesting use cases:
ls /proc/ | grep -E '^[0-9]+$'cat /proc/net/tcpcat /proc/<PID>/cmdlinepwd - Print Working DirectoryAlways know where you are in the file system.
pwd
# Output: /home/kali
cd - Change DirectoryMaster the art of moving around the file system.
# Navigate to a specific directory
cd /etc/
# Go to home directory (three ways)
cd ~
cd $HOME
cd
# Move up one directory
cd ..
# Move up two directories
cd ../..
# Return to previous directory
cd -
# Navigate using absolute path
cd /var/log/apache2/
# Navigate using relative path (from /var/log)
cd apache2/
Pro tips:
# Use Tab completion to save time
cd /etc/net[TAB] # Completes to /etc/network/
# Navigate to a directory with spaces (rare in Linux)
cd "My Folder"
cd My\ Folder
ls - List Directory ContentsThe most frequently used command - see what's in a directory.
# Basic listing
ls
# Long format (detailed)
ls -l
# Show hidden files (starting with .)
ls -a
# Long format with hidden files
ls -la
# Human-readable file sizes
ls -lh
# Sort by modification time (newest first)
ls -lt
# Recursive listing
ls -R
# Color-coded output (usually default)
ls --color=auto
# List only directories
ls -d */
# Show inode numbers
ls -i
Real-world pentesting examples:
# Find recently modified files (potential backdoors)
ls -lat /var/www/html/ | head -20
# Search for SUID binaries (privilege escalation)
ls -la /usr/bin/ | grep '^...s'
# List files with specific permissions
ls -l /etc/ | grep '^-rw-rw-rw-' # World-writable files
An absolute path starts from the root directory / and specifies the complete location.
# Always starts with /
cd /home/kali/Documents/
cat /etc/passwd
ls /var/log/
When to use:
A relative path is based on your current working directory.
# Assuming you're in /home/kali
cd Documents/ # Goes to /home/kali/Documents/
cd ../Downloads/ # Goes to /home/kali/Downloads/
cat ../../etc/passwd # Accesses /etc/passwd
Special path symbols:
. : Current directory.. : Parent directory~ : Home directory- : Previous directory# Execute a script in current directory
./script.sh
# Copy file to current directory
cp /tmp/file.txt .
# Move up and navigate
cd ../../var/log/
Linux supports several file types beyond regular files and directories.
# Check file type
file /etc/passwd
file /bin/bash
file /dev/sda
# Visual identification with ls -l
ls -l /
File type indicators (first character in ls -l):
| Symbol | Type | Description | Example |
|---|---|---|---|
- | Regular file | Standard files (text, binary, etc.) | -rw-r--r-- file.txt |
d | Directory | Folders containing other files | drwxr-xr-x home/ |
l | Symbolic link | Shortcut to another file | lrwxrwxrwx link -> target |
c | Character device | Serial devices (keyboard, mouse) | crw-rw---- /dev/tty1 |
b | Block device | Storage devices (hard drives) | brw-rw---- /dev/sda1 |
s | Socket | Inter-process communication | srwxrwxrwx /tmp/mysql.sock |
p | Named pipe (FIFO) | Inter-process communication | prw-r--r-- mypipe |
Symbolic links (symlinks) are pointers to other files or directories.
# Create a symbolic link
ln -s /path/to/original /path/to/link
# Example: Create a shortcut
ln -s /var/www/html ~/webroot
# View symlink target
readlink ~/webroot
ls -l ~/webroot
# Follow symlink
cd -P ~/webroot # Goes to actual directory
Pentesting context:
Files and directories starting with . are hidden by default.
# View hidden files
ls -a
# Common hidden configuration files
ls -la ~/ | grep '^\.' # View all dotfiles in home
# Important hidden files/directories
cat ~/.bashrc # Bash configuration
cat ~/.bash_history # Command history
ls ~/.ssh/ # SSH keys and config
cat ~/.mysql_history # MySQL command history
ls -la ~/.config/ # Application configurations
Security implications:
.bash_history: Contains all typed commands (may include passwords).ssh/: Private keys for authentication.aws/, .config/gcloud/: Cloud provider credentialsLocating files quickly is crucial for penetration testing and system administration.
find Command - The Swiss Army Knifefind is the most powerful file search tool, with extensive filtering options.
# Basic syntax
find /path/ -name "filename"
# Find by name (case-insensitive)
find /home/ -iname "*.txt"
# Find directories
find / -type d -name "config"
# Find regular files
find / -type f -name "passwd"
# Find files modified in last 7 days
find /var/log/ -mtime -7
# Find files modified more than 30 days ago
find /tmp/ -mtime +30
# Find files by size
find / -size +100M # Larger than 100MB
find / -size -1M # Smaller than 1MB
# Find files by permissions
find / -perm 777 # Exactly 777
find / -perm -4000 # SUID bit set
find / -perm /u+s # SUID (alternative syntax)
# Find files owned by user
find / -user root
find / -group www-data
# Execute commands on found files
find . -name "*.log" -exec cat {} \;
find / -perm -4000 -exec ls -l {} \;
# Combine multiple criteria
find /var/www/ -type f -name "*.php" -mtime -7
Pentesting use cases:
# Find SUID/SGID binaries (privilege escalation)
find / -perm -4000 -type f 2>/dev/null
find / -perm -2000 -type f 2>/dev/null
# Find world-writable files
find / -perm -002 -type f 2>/dev/null
# Find world-writable directories
find / -perm -002 -type d 2>/dev/null
# Find files containing passwords (in filename)
find / -name "*password*" 2>/dev/null
find / -name "*credential*" 2>/dev/null
# Find recently modified files (post-exploitation)
find /etc/ -type f -mmin -60 # Modified in last hour
# Find files by specific user
find / -user www-data 2>/dev/null
# Find writable directories
find / -type d -writable 2>/dev/null
# Find configuration files
find /etc/ -name "*.conf" 2>/dev/null
# Find SSH keys
find / -name "id_rsa" 2>/dev/null
find / -name "authorized_keys" 2>/dev/null
Note: 2>/dev/null redirects error messages (like "Permission denied") to discard them.
locate Command - Lightning Fast Searchlocate uses a pre-built database for instant searches (must be updated periodically).
# Update the database (run as root)
sudo updatedb
# Basic search
locate password
locate php.ini
# Case-insensitive search
locate -i PASSWORD
# Count results
locate -c "*.conf"
# Show only existing files (check if file still exists)
locate -e password.txt
# Limit results
locate -l 10 "*.log"
Advantages:
Disadvantages:
updatedb)which Command - Find Command Executableswhich locates executable binaries in your PATH.
# Find command location
which python
which nmap
which bash
# Check if command exists
which metasploit
# Show all matches in PATH
which -a python
Use cases:
whereis Command - Comprehensive Binary Searchwhereis locates binary, source, and man page files.
# Find binary, source, and man pages
whereis bash
# Output: bash: /bin/bash /etc/bash.bashrc /usr/share/man/man1/bash.1.gz
whereis nmap
whereis python3
# Only binary
whereis -b nmap
# Only manual pages
whereis -m nmap
# Only source code
whereis -s nmap
| Command | Speed | Database | Use Case |
|---|---|---|---|
find | Slow | No (real-time) | Complex searches, recent files, permissions |
locate | Very fast | Yes (updatedb) | Quick filename searches |
which | Fast | No (PATH only) | Find executables in PATH |
whereis | Fast | Yes (specific paths) | Find binaries, sources, man pages |
# List all users
cat /etc/passwd
cut -d: -f1 /etc/passwd # Extract usernames only
# Real users (UID >= 1000)
awk -F: '$3 >= 1000 {print $1}' /etc/passwd
# Users with login shells
grep -v '/nologin\|/false' /etc/passwd
# View groups
cat /etc/group
# Sudoers configuration
sudo cat /etc/sudoers
sudo ls /etc/sudoers.d/
# Password hashes (requires root)
sudo cat /etc/shadow
# Format: username:$id$salt$hash:lastchange:min:max:warn:inactive:expire
# Hash types:
# $1$ = MD5
# $2a$ or $2y$ = Blowfish
# $5$ = SHA-256
# $6$ = SHA-512
# Extract for cracking
sudo unshadow /etc/passwd /etc/shadow > hashes.txt
# Authentication logs
sudo tail -f /var/log/auth.log # Debian/Ubuntu
sudo tail -f /var/log/secure # RHEL/CentOS
# System logs
sudo tail -f /var/log/syslog # Debian/Ubuntu
sudo tail -f /var/log/messages # RHEL/CentOS
# Web server logs
sudo tail -f /var/log/apache2/access.log
sudo tail -f /var/log/apache2/error.log
sudo tail -f /var/log/nginx/access.log
# Failed login attempts
sudo grep "Failed password" /var/log/auth.log
# Successful sudo commands
sudo grep "COMMAND" /var/log/auth.log
# Network interfaces
cat /etc/network/interfaces # Debian/Ubuntu
cat /etc/sysconfig/network-scripts/ifcfg-eth0 # RHEL/CentOS
# DNS resolution
cat /etc/resolv.conf
# Host mappings
cat /etc/hosts
# Active connections (proc interface)
cat /proc/net/tcp
cat /proc/net/udp
# System-wide cron jobs
cat /etc/crontab
ls /etc/cron.d/
ls /etc/cron.daily/
ls /etc/cron.hourly/
ls /etc/cron.weekly/
ls /etc/cron.monthly/
# User cron jobs
sudo crontab -l -u root
crontab -l
sudo ls /var/spool/cron/crontabs/
# Systemd timers (modern alternative)
systemctl list-timers
# SSH configuration
cat /etc/ssh/sshd_config
# Apache configuration
ls /etc/apache2/
cat /etc/apache2/apache2.conf
ls /etc/apache2/sites-enabled/
# Nginx configuration
ls /etc/nginx/
cat /etc/nginx/nginx.conf
ls /etc/nginx/sites-enabled/
# MySQL/MariaDB
cat /etc/mysql/my.cnf
ls /etc/mysql/conf.d/
# Database connection strings
find /var/www/ -name "*.php" -exec grep -i "mysql_connect\|mysqli" {} +
# Default web roots
/var/www/html/ # Apache/Nginx default
/usr/share/nginx/html/ # Nginx alternative
/var/www/ # General web directory
# Check web server user
ps aux | grep -E 'apache|nginx|httpd'
# Common: www-data, apache, nginx
# Find writable web directories
find /var/www/ -type d -writable 2>/dev/null
# Find upload directories
find /var/www/ -type d -name "upload*" -o -name "files"
# Find configuration files with credentials
find /var/www/ -name "config.php" -o -name "wp-config.php" -o -name ".env"
# SSH keys
find / -name "id_rsa" 2>/dev/null
find / -name "id_dsa" 2>/dev/null
find / -name "authorized_keys" 2>/dev/null
# Configuration files with passwords
find / -name "*.conf" -exec grep -i "password" {} + 2>/dev/null
find /home/ -name ".bash_history" 2>/dev/null
# Database files
find / -name "*.db" 2>/dev/null
find / -name "*.sqlite" 2>/dev/null
# Backup files
find / -name "*.bak" 2>/dev/null
find / -name "*.backup" 2>/dev/null
find /var/backups/ -type f 2>/dev/null
# Cloud credentials
find / -name "credentials" 2>/dev/null
find / -name "*.pem" 2>/dev/null
find /home/ -name ".aws" 2>/dev/null
Objective: Familiarize yourself with the Linux directory structure.
Navigate to the root directory and list all directories:
cd /
ls -l
Explore each major directory using cd and ls:
cd /etc
ls -lh
cd /var/log
ls -lh
cd /usr/bin
ls | wc -l # Count binaries
Find your way back home using different methods:
cd ~
cd
cd $HOME
Objective: Practice using find, locate, and which.
Find all .conf files in /etc:
find /etc/ -name "*.conf" 2>/dev/null
Locate all Python executables:
which -a python python3
whereis python3
Find recently modified files in /tmp:
find /tmp/ -type f -mmin -60
Search for SUID binaries:
find / -perm -4000 -type f 2>/dev/null | tee suid-binaries.txt
Objective: Practice gathering system information.
List all users on the system:
cat /etc/passwd | cut -d: -f1 | sort
Find users with UID 0 (root privileges):
awk -F: '$3 == 0 {print $1}' /etc/passwd
Check for users with empty passwords:
sudo awk -F: '$2 == "" {print $1}' /etc/shadow
List all running services:
systemctl list-units --type=service --state=running
Objective: Learn to navigate and analyze system logs.
View the last 20 authentication attempts:
sudo tail -20 /var/log/auth.log
Find failed SSH login attempts:
sudo grep "Failed password" /var/log/auth.log | tail -10
Count failed login attempts by IP:
sudo grep "Failed password" /var/log/auth.log | awk '{print $(NF-3)}' | sort | uniq -c | sort -rn
Monitor logs in real-time:
sudo tail -f /var/log/syslog
Objective: Practice web application file system analysis.
Find the web root:
ls -la /var/www/html/
Search for PHP files:
find /var/www/ -name "*.php" 2>/dev/null
Look for configuration files:
find /var/www/ -name "config*.php" -o -name ".env" -o -name "wp-config.php" 2>/dev/null
Identify upload directories:
find /var/www/ -type d \( -name "upload*" -o -name "files" -o -name "media" \) 2>/dev/null
Objective: Document a target system's layout.
Create a script to map the file system:
#!/bin/bash
# filesystem-mapper.sh
echo "[+] File System Reconnaissance"
echo "================================"
echo ""
echo "[*] System Information:"
uname -a
echo ""
echo "[*] Disk Usage:"
df -h
echo ""
echo "[*] Users (UID >= 1000):"
awk -F: '$3 >= 1000 {print $1}' /etc/passwd
echo ""
echo "[*] SUID Binaries:"
find / -perm -4000 -type f 2>/dev/null
echo ""
echo "[*] World-Writable Directories:"
find / -type d -perm -002 2>/dev/null | head -20
echo ""
echo "[*] Cron Jobs:"
cat /etc/crontab 2>/dev/null
ls -la /etc/cron.* 2>/dev/null
echo ""
echo "[+] Reconnaissance Complete"
Run it:
chmod +x filesystem-mapper.sh
./filesystem-mapper.sh > system-map.txt
After gaining initial access to a system:
# Verify access and location
pwd
whoami
id
# Quick system enumeration
uname -a
cat /etc/os-release
# Check user privileges
sudo -l
# Identify current directory permissions
ls -la
# Search for SUID binaries
find / -perm -4000 -type f 2>/dev/null
# Check for writable /etc/passwd
ls -la /etc/passwd
# Look for sudo misconfigurations
sudo -l
cat /etc/sudoers 2>/dev/null
# Check for interesting cronjobs
cat /etc/crontab
ls -la /etc/cron.*
# Find writable scripts or binaries
find / -writable -type f 2>/dev/null | grep -v proc
# Command history
cat ~/.bash_history
cat ~/.mysql_history
cat ~/.psql_history
# Configuration files
find /home/ -name "*.conf" 2>/dev/null
find /var/www/ -name "config*.php" 2>/dev/null
# SSH keys
find / -name "id_rsa" 2>/dev/null
cat ~/.ssh/id_rsa
cat ~/.ssh/authorized_keys
# Database credentials
find / -name "*.sql" 2>/dev/null
grep -r "password" /var/www/ 2>/dev/null | grep -i db
# Identify other users and systems
cat /etc/passwd
cat /etc/hosts
cat ~/.ssh/known_hosts
# Network configuration
ifconfig
ip addr
cat /etc/network/interfaces
# Active connections
netstat -antp
ss -antp
cat /proc/net/tcp
# Installed software
ls /opt/
ls /usr/local/bin/
dpkg -l # Debian/Ubuntu
rpm -qa # RHEL/CentOS
# Add to your prompt (edit ~/.bashrc)
PS1='\u@\h:\w\$ '
# Shows: username@hostname:/current/path$
Press Tab to autocomplete file and directory names. Press Tab twice to see all possibilities.
# Use cd - to toggle between directories
cd /etc/
cd /var/log/
cd - # Back to /etc/
cd - # Back to /var/log/
# Use pushd and popd for directory stack
pushd /etc/
pushd /var/log/
pushd /tmp/
dirs # View stack
popd # Return to previous
When searching the entire filesystem, suppress "Permission denied" errors:
find / -name "config.php" 2>/dev/null
# Find and count
find /etc/ -name "*.conf" 2>/dev/null | wc -l
# Find and display
find / -perm -4000 2>/dev/null | xargs ls -lh
# Grep through multiple files
find /var/www/ -name "*.php" -exec grep -l "mysql_connect" {} \;
Save command output for reporting:
find / -perm -4000 2>/dev/null | tee suid-report.txt
uname -a >> system-info.txt
cat /etc/passwd >> system-info.txt
# ls -l output format:
# -rwxr-xr-x 1 owner group size date name
# ↑ ↑ ↑ ↑ ↑ ↑
# │ │ │ │ │ └─ File type
# │ │ │ │ └─── Owner permissions (rwx = 7)
# │ │ │ └───── Group permissions (r-x = 5)
# │ │ └─────── Others permissions (r-x = 5)
# │ └───────── Number of hard links
# └─────────── File type (- = file, d = directory, l = link)
# Permission calculation:
# r (read) = 4
# w (write) = 2
# x (execute) = 1
# rwx = 7, rw- = 6, r-x = 5, r-- = 4
Add to ~/.bashrc:
alias ll='ls -lah'
alias ..='cd ..'
alias ...='cd ../..'
alias h='history'
alias ports='netstat -antp'
alias fs='find / -name'
Reload:
source ~/.bashrc
/root and // is the root directory (top of the file system)/root is the home directory of the root user# Bad - cluttered output
find / -name config.php
# Good - clean output
find / -name config.php 2>/dev/null
# Wrong
cat my file.txt # Tries to cat "my" and "file.txt"
# Right
cat "my file.txt"
cat my\ file.txt
# Very dangerous - redirects to the same file
grep pattern file.txt > file.txt # Empties file.txt!
# Safe - use a different output file
grep pattern file.txt > output.txt
.# Dangerous if you're in the wrong location
rm -rf .
# Always verify first
pwd
ls -la
/bin, /usr/bin, /sbin, and /usr/sbin?A: These directories traditionally served different purposes:
/bin: Essential command-line utilities needed for single-user mode and system repair (bash, ls, cat, cp, rm)/sbin: Essential system administration commands needed for boot and recovery (fsck, init, reboot, iptables)/usr/bin: User commands and applications for normal system operation (less critical than /bin)/usr/sbin: System administration tools for regular multi-user operationThe distinction was based on:
/bin and /sbin contain critical tools needed if /usr isn't mountedbin directories for regular users, sbin for system administratorsModern systems: Many distributions now symlink /bin → /usr/bin and /sbin → /usr/sbin because separate /usr partitions are less common. Kali Linux follows this unified approach.
For pentesters: Search both locations when hunting for binaries:
find /bin /sbin /usr/bin /usr/sbin -name "python*"
A: Use find with time-based options:
# Files modified in the last N days
find / -type f -mtime -7 # Last 7 days
# Files modified in the last N minutes
find / -type f -mmin -60 # Last 60 minutes
# Files modified after a specific date
touch -t 202601150000 /tmp/timestamp # Jan 15, 2026 00:00
find / -newer /tmp/timestamp 2>/dev/null
# More precise: files modified between dates
touch -t 202601150000 /tmp/start
touch -t 202601200000 /tmp/end
find / -newer /tmp/start ! -newer /tmp/end 2>/dev/null
# Focus on critical directories
find /etc /var/www /home -type f -mtime -1
# Sort by modification time
find /var/www/ -type f -mtime -7 -exec ls -lt {} + | head -20
Incident response tip: Attackers often modify /etc/passwd, /etc/shadow, web shell files, or cron jobs. Check these first:
ls -la /etc/passwd /etc/shadow /etc/crontab
find /var/www/ -name "*.php" -mtime -1
A: SUID (Set User ID) is a special permission that allows a program to run with the privileges of its owner (usually root), regardless of who executes it.
How it works:
# Example: ping needs root to create raw sockets
ls -l /bin/ping
# -rwsr-xr-x ... /bin/ping
# ↑
# s = SUID bit
When you run ping, it temporarily executes with root privileges even though you're a regular user.
Why pentesters care:
nmap --interactive in old versions)Find SUID binaries:
# Find all SUID files
find / -perm -4000 -type f 2>/dev/null
# Find SGID files (similar concept, group ID)
find / -perm -2000 -type f 2>/dev/null
# Find both
find / -perm -4000 -o -perm -2000 2>/dev/null
# Detailed listing
find / -perm -4000 -type f -exec ls -lh {} \; 2>/dev/null
# Common exploitable SUID binaries to check:
# - find, nmap (old versions), vim, bash, more, less, nano, cp, mv
Exploitation example (if find has SUID):
find /home -exec /bin/sh -p \; # Spawns root shell
Resources:
A: Follow these safety practices:
1. Use a Virtual Machine:
# Practice in Kali Linux VM or any disposable Linux instance
# Quick setup: https://andraxpentester.in/tutorials/how-to-install-kali-linux-in-virtualbox-complete-2026-guide
2. Create Snapshots:
3. Use a Test Directory:
# Create a safe playground
mkdir -p ~/practice-area
cd ~/practice-area
# Create test files and directories
mkdir -p test/{dir1,dir2,dir3}
touch test/file{1..10}.txt
echo "Sample content" > test/file1.txt
# Practice here instead of system directories
find ~/practice-area -name "*.txt"
ls -la ~/practice-area/test/
4. Use Read-Only Commands First:
Safe commands (won't modify anything):
ls, cat, less, morefind (without -exec or -delete)pwd, cd, which, whereisgrep, head, tailPotentially dangerous commands:
rm, mv, chmod, chownfind with -exec or -delete> (redirect/overwrite)dd, mkfs5. Use -i Interactive Mode:
# Prompt before each removal
rm -i file.txt
# Prompt before overwriting
mv -i source.txt dest.txt
cp -i file1 file2
6. Double-Check Before Destructive Operations:
# Bad - immediate deletion
rm -rf /path/to/dir
# Good - verify first
ls /path/to/dir
du -sh /path/to/dir
# Then, if correct:
rm -rf /path/to/dir
7. Add Safety Aliases to ~/.bashrc:
alias rm='rm -i'
alias mv='mv -i'
alias cp='cp -i'
8. Practice on Purpose-Built Systems:
A: Use these memory techniques and reference materials:
1. Create a Visual Cheat Sheet:
Save this as ~/filesystem-cheatsheet.txt:
Linux File System Quick Reference
==================================
/ Root (everything starts here)
/root Root user's home
/home User home directories
/etc Configuration files
/var Variable data (logs, databases)
/tmp Temporary files (world-writable)
/usr User programs and data
/opt Optional/third-party software
/bin Essential commands
/sbin System admin commands
/dev Device files
/proc Process information (virtual)
/var/log System logs
Navigation:
cd Change directory
cd ~ Go home
cd .. Up one level
cd - Previous directory
pwd Print working directory
Listing:
ls -la Long format, all files
ls -lh Human-readable sizes
ls -lt Sort by time
Finding:
find / -name "file" Find by name
find / -type f -mtime -7 Modified last 7 days
find / -perm -4000 SUID binaries
locate file Fast search (uses DB)
which command Find in PATH
2. Practice Regularly:
# Daily practice routine (5 minutes)
cd /
ls -la
pwd
cd /etc && ls -lh | head
cd /var/log && ls -lh
find /home -name "*.txt" 2>/dev/null | head -5
cd ~
3. Use Mnemonics:
/etc = "Et Cetera" (configuration files)/var = "Variable" (changing data like logs)/tmp = "Temporary"/usr = "Unix System Resources" (not "user"!)/opt = "Optional" packages/bin = "Binaries" (executables)4. Create Path Association Stories:
"When I log in as root (/root), I check the system logs (/var/log) and review configuration files (/etc) before making changes. Then I check my tools in /opt and look at web applications in /var/www."
5. Use Command History:
# Search command history
history | grep find
Ctrl + R # Then type search term (interactive)
# Save useful commands
echo "find / -perm -4000 2>/dev/null" >> ~/useful-commands.txt
6. Build Muscle Memory:
Set yourself these weekly challenges:
find with 3 different criteria each day7. Keep Reference Cards:
Print and keep near your workstation:
8. Use Spaced Repetition:
Use flashcard apps (Anki, Quizlet) with questions like:
/etc/shadowfind / -perm -4000 2>/dev/null/var/log/9. Integrate Into Practice:
Whenever you work through pentesting tutorials (like those on andraxpentester.in), actively use these commands rather than copy-pasting.
10. Bookmark Quality References:
Now that you understand the Linux file system, you're ready to:
cat, grep, sed, awk for working with file contents/proc filesystem, and process manipulationContinue your Kali Linux learning path with our tutorial series, and practice these concepts in real-world scenarios. Remember, consistent hands-on practice is the key to mastery.
The Linux file system hierarchy is the foundation of effective system administration and penetration testing. By understanding the purpose of each directory, mastering navigation commands, and knowing where to look for critical files, you've taken a significant step toward becoming a proficient ethical hacker.
Key takeaways:
/cd, ls, pwd) are your primary toolsfind command is essential for comprehensive file searches/etc, /var/log, /home, and application-specific directoriesRemember: knowledge alone isn't enough. Set up your Kali Linux environment, practice these commands daily, and apply them in realistic scenarios. The file system is your roadmap - learn to read it fluently, and you'll navigate any Linux system with confidence.
Happy hacking, and stay ethical!
About the Author: Syed Abrar (Andrax Pentester) is a cybersecurity professional specializing in penetration testing and ethical hacking education. Follow more tutorials and security research at andraxpentester.in.
Disclaimer: The techniques described in this tutorial are for educational purposes and authorized security testing only. Always obtain proper authorization before testing any system you don't own. Unauthorized access to computer systems is illegal.
25 min read
A step-by-step penetration testing lab guide. Learn how to setup a test environment, identify BOLA vulnerabilities using Burp Suite Repeater/Match & Replace, and implement secure code fixes.
45 min read
Sign in to leave a comment.