By Davy Rogers. Use these techniques only in environments you own or have explicit permission to test.

What is Linux

Linux is a free, open-source operating system kernel that forms the foundation of countless operating systems (called distributions or "distros"). Created by Linus Torvalds in 1991, Linux has become the backbone of cybersecurity work, powering everything from penetration testing tools to enterprise servers and Android devices.

What You'll Learn

  • What Linux is and why it matters for cybersecurity
  • Popular Linux distributions for security work
  • Basic Linux architecture and philosophy
  • Why penetration testers use Linux
  • How to get started with Linux

Why Linux for Cybersecurity?

Linux dominates the cybersecurity landscape for several compelling reasons:

1. Open Source and Transparent

  • Source code is publicly available for inspection
  • No hidden backdoors or proprietary restrictions
  • Community-driven security improvements
  • Learn how the system actually works

2. Powerful Command Line

  • The terminal is the primary interface for most security tools
  • Scripting and automation capabilities
  • Efficient for remote administration
  • Chain commands together with pipes and redirection

3. Security Tools Ecosystem

  • Most pentesting tools are built for Linux first
  • Package managers make tool installation easy
  • Native support for security-focused distributions
  • Better compatibility with exploit code and frameworks

4. Customization and Control

  • Full control over every aspect of the system
  • Lightweight configurations possible
  • Remove unnecessary services
  • Tailor the OS to your specific needs

5. Server Dominance

  • 96.3% of the top 1 million web servers run Linux
  • Understanding Linux = understanding target systems
  • Cloud infrastructure (AWS, Azure, GCP) is primarily Linux
  • Most IoT and embedded devices run Linux variants

Linux vs. Windows vs. macOS

FeatureLinuxWindowsmacOS
CostFreePaidPaid (with Mac hardware)
Source CodeOpenClosedClosed (Unix-based)
CustomizationExtensiveLimitedLimited
Security ToolsNativeRequires WSL/VMsSome native, some limited
Learning CurveSteep initiallyFamiliar to mostModerate
Enterprise ServersDominantCommonRare
Package ManagementExcellentImprovingGood

For Penetration Testing:

Kali Linux šŸ„‡

  • Best for: Penetration testing and security auditing
  • Tools included: 600+ pre-installed security tools
  • Based on: Debian
  • Why choose it: Industry standard, most tutorials use Kali
  • Who maintains it: Offensive Security (creators of OSCP)
# Kali comes with tools like:
nmap          # Network scanning
metasploit    # Exploitation framework
burpsuite     # Web app testing
wireshark     # Packet analysis
john          # Password cracking

Parrot Security OS

  • Best for: Penetration testing with a focus on privacy
  • Tools included: 700+ security tools
  • Based on: Debian
  • Why choose it: Lighter than Kali, built-in anonymity tools
  • Unique features: AnonSurf for anonymity, more lightweight

BlackArch Linux

  • Best for: Advanced users wanting maximum tool selection
  • Tools included: 2800+ security tools
  • Based on: Arch Linux
  • Why choose it: Largest security tool repository
  • Learning curve: Steeper (Arch-based)

For General Use and Learning:

Ubuntu

  • Best for: Beginners, general purpose
  • Why: User-friendly, massive community support
  • Great for: Learning Linux basics before Kali

Debian

  • Best for: Stable systems
  • Why: Rock-solid stability, foundation for Ubuntu/Kali
  • Great for: Servers and long-term projects

Fedora

  • Best for: Cutting-edge features
  • Why: Latest technologies, backed by Red Hat
  • Great for: Developers and advanced users

Linux Architecture Basics

Understanding Linux structure is crucial for security work:

The Linux Kernel

  • Core of the operating system
  • Manages hardware, memory, and processes
  • Provides system calls for user programs
  • We'll cover this in depth in the next lesson

The Filesystem Hierarchy

/                   # Root directory (everything starts here)
ā”œā”€ā”€ bin/           # Essential user binaries (ls, cp, cat)
ā”œā”€ā”€ boot/          # Boot loader files, kernel
ā”œā”€ā”€ dev/           # Device files (hard drives, USB, etc.)
ā”œā”€ā”€ etc/           # Configuration files
ā”œā”€ā”€ home/          # User home directories
│   └── username/  # Your personal files
ā”œā”€ā”€ lib/           # Shared libraries
ā”œā”€ā”€ media/         # Mount points for removable media
ā”œā”€ā”€ mnt/           # Temporary mount points
ā”œā”€ā”€ opt/           # Optional software packages
ā”œā”€ā”€ proc/          # Process and system information
ā”œā”€ā”€ root/          # Root user's home directory
ā”œā”€ā”€ sbin/          # System binaries (admin tools)
ā”œā”€ā”€ tmp/           # Temporary files (cleared on reboot)
ā”œā”€ā”€ usr/           # User programs and data
│   ā”œā”€ā”€ bin/       # User binaries
│   ā”œā”€ā”€ local/     # Locally installed software
│   └── share/     # Shared data
└── var/           # Variable data (logs, databases)
    └── log/       # System logs

Important Directories for Penetration Testing:

  • /etc/passwd - User account information
  • /etc/shadow - Encrypted passwords (requires root)
  • /var/log/ - System and application logs
  • /home/ - User files and potential sensitive data
  • /tmp/ - Often writable, useful for file transfers
  • /opt/ - Third-party applications may have misconfigurations

Linux Philosophy

Understanding the Linux philosophy helps you work more effectively:

1. Everything is a File

  • Regular files, directories, and even hardware devices
  • Consistent interface for interacting with the system
  • /dev/sda is your hard drive, /dev/null is a black hole

2. Small, Focused Tools

  • Each program does one thing well
  • Combine tools to accomplish complex tasks
  • Examples: grep, sed, awk, cut

3. Piping and Redirection

  • Connect program outputs to program inputs
  • Build powerful command chains
cat file.txt | grep "error" | sort | uniq -c | sort -nr

4. Case Sensitivity

  • File.txt, file.txt, and FILE.TXT are three different files
  • Commands are lowercase by convention
  • Matters for scripting and file operations

5. No File Extensions Required

  • File type determined by content, not extension
  • file command examines actual file type
  • Execute permissions matter more than .exe

Getting Started with Linux

Pros: Safe, doesn't affect your main system, easy snapshots Tools: VirtualBox (free), VMware Workstation/Fusion

# On Windows, download VirtualBox:
# https://www.virtualbox.org/

# Then download Kali Linux VM image:
# https://www.kali.org/get-kali/#kali-virtual-machines

Option 2: Dual Boot

Pros: Full hardware performance, native experience Cons: Requires disk partitioning, slight risk to existing OS

Option 3: Windows Subsystem for Linux (WSL)

Pros: Linux tools within Windows, no reboot needed Cons: Not all pentesting tools work, GUI limitations

# Install WSL 2 on Windows:
wsl --install -d kali-linux

Option 4: Live USB

Pros: Portable, no installation, leaves no traces Cons: Slower performance, changes don't persist

Your First Linux Commands

Once you have Linux running, try these essential commands:

pwd                    # Print working directory (where am I?)
ls                     # List files in current directory
ls -la                 # List all files with details
cd /home/kali          # Change to /home/kali directory
cd ..                  # Go up one directory
cd ~                   # Go to your home directory

File Operations:

touch file.txt         # Create empty file
cat file.txt           # Display file contents
nano file.txt          # Edit file (beginner-friendly editor)
cp file.txt backup.txt # Copy file
mv file.txt newname.txt # Move/rename file
rm file.txt            # Delete file (careful!)

System Information:

whoami                 # Current username
hostname               # Computer name
uname -a               # System information
ip addr                # IP address configuration
ps aux                 # Running processes
top                    # Real-time process viewer (press 'q' to quit)

Getting Help:

man ls                 # Manual page for 'ls' command
ls --help              # Quick help for 'ls'
apropos search         # Search for commands by keyword

Essential Concepts

Users and Permissions

  • Root user: Administrator (superuser), can do anything
  • Regular users: Limited permissions for safety
  • sudo: Execute commands with root privileges
sudo apt update        # Run 'apt update' as root
sudo -i                # Become root user
exit                   # Exit root shell

Package Management (Kali/Ubuntu/Debian)

sudo apt update        # Update package lists
sudo apt upgrade       # Upgrade installed packages
sudo apt install nmap  # Install nmap
sudo apt remove nmap   # Uninstall nmap
apt search keyword     # Search for packages

File Permissions

ls -l file.txt
# Output: -rw-r--r-- 1 user group 1234 Oct 8 file.txt
#         --------- - ---- ----- ---- ------ --------
#         permissions links owner group size date   name

# Permissions breakdown:
# - (file type: - = file, d = directory, l = link)
# rw- (owner: read, write, no execute)
# r-- (group: read only)
# r-- (others: read only)

Common Pitfalls for Beginners

āŒ Using root account for everything - Security risk, easy to break things

āœ… Use regular user account, sudo when needed

āŒ Forgetting case sensitivity - cd Desktop ≠ cd desktop

āœ… Use tab completion to avoid typos

āŒ Not reading error messages - They usually tell you what's wrong

āœ… Read carefully, Google error messages

āŒ Running random commands from internet - Can harm your system

āœ… Understand what a command does before running it

āŒ Not making backups - Data loss is painful

āœ… Regular backups, especially before major changes

Try It Yourself

Beginner Tasks:

  1. Install Linux in a VM or WSL
  2. Navigate the filesystem using cd, ls, pwd
  3. Create a practice directory and make some test files
  4. Read man pages for commands you want to learn
  5. Update your system using the package manager
  6. Customize your terminal (change prompt, colors)

Practice Challenge:

Create this directory structure using only the command line:

practice/
ā”œā”€ā”€ docs/
│   ā”œā”€ā”€ readme.txt
│   └── notes.txt
ā”œā”€ā”€ scripts/
│   └── hello.sh
└── backups/
Solution (try it yourself first!)
mkdir -p practice/{docs,scripts,backups}
touch practice/docs/readme.txt practice/docs/notes.txt
touch practice/scripts/hello.sh
tree practice  # View the structure (install 'tree' if needed)

Resources for Learning Linux

Interactive Learning:

Books:

  • "The Linux Command Line" by William Shotts (free PDF)
  • "Linux Basics for Hackers" by OccupyTheWeb
  • "How Linux Works" by Brian Ward

Cheat Sheets:

Video Channels:

  • NetworkChuck - Beginner-friendly Linux tutorials
  • LearnLinuxTV - Comprehensive Linux courses
  • The Cyber Mentor - Security-focused Linux content

Next Steps

  1. Next lesson: Learn about the Linux Kernel in detail
  2. Practice daily: Spend 30 minutes in the terminal each day
  3. Explore your system: Navigate directories, read man pages
  4. Try a challenge: Start the Bandit wargame on OverTheWire
  5. Join communities: r/linux4noobs, r/linuxquestions

Remember: Linux has a learning curve, but it's worth it. Every expert was once a beginner who didn't give up!


"Linux is only free if your time has no value." - Jamie Zawinski (tongue-in-cheek, but there's truth: invest time to learn, reap benefits forever!)