beginner March 16, 2026 6 min read

Linux Basics Every Hacker Needs to Know: Your Foundation for Cybersecurity Success

Whether you're starting your cybersecurity journey or looking to strengthen your fundamentals, mastering Linux is non-negotiable. From penetration testing to incident response, nearly every cybersecurity tool and technique relies on Linux proficiency. This comprehensive guide covers the essential Linux skills that will transform you from a curious beginner into a confident security professional.

Linux powers the majority of servers worldwide, forms the backbone of most cybersecurity tools, and provides the flexibility that security professionals need to perform their work effectively. Unlike other operating systems, Linux gives you complete control over your system, making it the preferred choice for ethical hackers, penetration testers, and security researchers.

Essential Linux Distributions for Security Work

Not all Linux distributions are created equal when it comes to cybersecurity. While any Linux distro can be configured for security work, some are specifically designed with hackers and security professionals in mind.

Kali Linux is the gold standard for penetration testing. Based on Debian, it comes pre-installed with over 600 security tools, making it perfect for beginners who want everything ready out of the box. Kali includes tools for network analysis, vulnerability assessment, forensics, and exploitation.

Parrot Security OS offers a lighter alternative to Kali while still providing comprehensive security tools. It's particularly popular among privacy-conscious users and includes anonymous surfing capabilities alongside traditional penetration testing tools.

Ubuntu remains an excellent choice for those who want to build their security toolkit gradually. Its extensive documentation and large community make it beginner-friendly, while its stability makes it suitable for professional environments.

For this guide, we'll focus on commands and techniques that work across all major distributions, with specific notes where certain tools are distribution-specific.

Command Line Mastery: Your Most Powerful Weapon

The command line is where Linux truly shines, and for security professionals, it's absolutely essential. Here are the fundamental commands every aspiring hacker must master:

File System Navigation and Manipulation

Understanding the Linux file system is crucial for any security work. The hierarchical structure, with root (/) at the top, contains everything from system files to user data.

# Navigate the file system
cd /home/user          # Change to specific directory
cd ~                   # Go to home directory
cd -                   # Return to previous directory
pwd                    # Print working directory

# List files and directories
ls -la                 # Detailed listing with hidden files
ls -lh                 # Human-readable file sizes
find / -name "*.conf" 2>/dev/null  # Find all config files

The find command is particularly powerful for security work. It can locate files by name, size, permissions, or modification time - essential when searching for suspicious files or configuration issues.

Process Management and System Monitoring

Monitoring system processes is fundamental to understanding what's happening on a system, whether you're investigating a potential breach or planning your next move during a penetration test.

# Process monitoring
ps aux                 # List all running processes
top                    # Real-time process monitoring
htop                   # Enhanced version of top (if installed)
kill -9 [PID]         # Forcefully terminate a process

# System information
uname -a               # System information
whoami                 # Current user
id                     # User and group IDs
w                      # Who is logged in and what they're doing

Understanding process management helps you identify suspicious activities, maintain stealth during authorized testing, and clean up after security assessments.

Network Analysis Commands

Network reconnaissance forms the foundation of most security assessments. These commands help you understand network topology, identify running services, and gather intelligence about your target.

# Network reconnaissance
netstat -tulpn         # Show all listening ports
ss -tulpn              # Modern replacement for netstat
nmap -sS 192.168.1.0/24  # TCP SYN scan of local network
ping -c 4 google.com   # Test connectivity

# Network configuration
ifconfig               # Display network interfaces (older systems)
ip addr show           # Modern way to show interfaces
route -n               # Display routing table
arp -a                 # Show ARP cache

File Permissions and Security Fundamentals

Linux permissions are often the difference between a successful security assessment and hitting a dead end. Understanding and manipulating permissions is crucial for privilege escalation, maintaining access, and understanding system security.

Understanding Permission Structure

Linux uses a three-tier permission system: owner, group, and others. Each tier can have read (r), write (w), and execute (x) permissions.

# Check file permissions
ls -la filename.txt

# Example output: -rw-r--r-- 1 user user 1024 Jan 15 10:30 filename.txt
# -rw-r--r-- breaks down as:
# - = file type (- for file, d for directory)
# rw- = owner permissions (read, write, no execute)
# r-- = group permissions (read only)
# r-- = others permissions (read only)

Modifying Permissions for Security Testing

During security assessments, you'll often need to modify permissions to execute tools, hide files, or simulate various security scenarios.

# Change permissions using chmod
chmod 755 script.sh    # Make script executable
chmod +x tool.py       # Add execute permission
chmod 600 private.key  # Only owner can read/write

# Change ownership
sudo chown user:group filename  # Change owner and group
sudo chown -R user:user directory/  # Recursively change ownership

# Advanced permission commands
umask                  # Show default permission mask
lsattr filename        # Show extended attributes
chattr +i filename     # Make file immutable

SUID, SGID, and Sticky Bits

These special permissions are goldmines for privilege escalation. Understanding them is essential for both finding vulnerabilities and securing systems.

# Find SUID binaries (common privilege escalation vector)
find / -perm -4000 -type f 2>/dev/null

# Find SGID binaries
find / -perm -2000 -type f 2>/dev/null

# Find world-writable directories
find / -perm -002 -type d 2>/dev/null

# Set special permissions
chmod 4755 binary      # Set SUID bit
chmod 2755 directory   # Set SGID bit
chmod 1755 directory   # Set sticky bit

Text Processing and Log Analysis

Security professionals spend considerable time analyzing logs, configuration files, and command output. Linux provides powerful text processing tools that can quickly extract meaningful information from massive amounts of data.

Essential Text Processing Tools

# View file contents
cat /var/log/auth.log  # Display entire file
head -20 logfile.txt   # First 20 lines
tail -50 logfile.txt   # Last 50 lines
tail -f access.log     # Follow log file in real-time

# Search and filter
grep "Failed password" /var/log/auth.log  # Find failed login attempts
grep -r "password" /etc/  # Recursively search for "password"
grep -v "INFO" app.log    # Exclude lines containing "INFO"
grep -E "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}" file.txt  # Find IP addresses

Advanced Text Manipulation

These tools become invaluable when processing large datasets or parsing complex log files during incident response or forensic analysis.

# Cut and sort data
cut -d' ' -f1 access.log | sort | uniq -c | sort -nr  # Count unique IP addresses
awk '{print $1}' access.log  # Print first column using awk
sed 's/old/new/g' file.txt   # Replace all occurrences of "old" with "new"

# Combine commands for powerful analysis
cat access.log | grep "404" | cut -d' ' -f1 | sort | uniq -c | sort -nr | head -10
# Find top 10 IPs generating 404 errors

System Security and Hardening Basics

Understanding how to secure a Linux system is just as important as knowing how to exploit vulnerabilities. This knowledge makes you a more well-rounded security professional and helps you provide valuable remediation advice.

Service Management

Controlling which services run on a system is fundamental to security. Unnecessary services increase the attack surface and potential vulnerabilities.

# SystemD-based systems (most modern distributions)
systemctl list-units --type=service  # List all services
systemctl status ssh                  # Check specific service status
sudo systemctl stop apache2          # Stop a service
sudo systemctl disable apache2       # Prevent service from starting at boot

# Check listening services
netstat -tulpn | grep LISTEN
ss -tulpn

User Account Management

Proper user management is critical for maintaining system security and conducting privilege escalation assessments.

# User information
cat /etc/passwd        # List all user accounts
cat /etc/shadow        # Password hashes (requires root)
cat /etc/group         # Group information

# User management commands
sudo adduser newuser   # Add new user account
sudo deluser olduser   # Remove user account
sudo passwd username   # Change user password
groups username        # Show user's groups

Practical Scripting for Automation

Automation is key to efficient security work. Bash scripting allows you to automate repetitive tasks, create custom tools, and chain commands together for complex operations.

Basic Bash Scripting

#!/bin/bash
# Simple network scanner script

echo "Starting network scan..."
network="192.168.1"

for i in {1..254}; do
    ip="$network.$i"
    ping -c 1 -W 1 $ip > /dev/null 2>&1
    if [ $? -eq 0 ]; then
        echo "$ip is alive"
    fi
done

echo "Scan complete!"

This simple script demonstrates variables, loops, and conditional statements - the building blocks of more complex automation scripts.

One-Liners for Quick Tasks

These powerful one-liners can save significant time during security assessments:

# Find recently modified files
find /home -type f -mtime -7 -ls

# Monitor network connections in real-time
watch -n 1 'netstat -tulpn'

# Quick port scan without nmap
for port in {20..25} {53,80,110,443,993,995}; do echo >/dev/tcp/192.168.1.1/$port && echo "Port $port is open"; done 2>/dev/null

Next Steps: Building Your Linux Security Toolkit

Mastering these Linux fundamentals provides the foundation for advanced cybersecurity work. To continue your journey, focus on these key areas:

Expand your tool knowledge: Learn specialized security tools like Metasploit, Burp Suite, and Wireshark. Understanding the Linux foundation makes learning these tools much easier.

Practice on vulnerable systems: Use platforms like VulnHub, HackTheBox, or TryHackMe to apply your Linux skills in realistic scenarios. Set up your own lab with intentionally vulnerable applications

Want more cybersecurity tutorials delivered to your inbox?

Subscribe Free →