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
| Feature | Linux | Windows | macOS |
|---|---|---|---|
| Cost | Free | Paid | Paid (with Mac hardware) |
| Source Code | Open | Closed | Closed (Unix-based) |
| Customization | Extensive | Limited | Limited |
| Security Tools | Native | Requires WSL/VMs | Some native, some limited |
| Learning Curve | Steep initially | Familiar to most | Moderate |
| Enterprise Servers | Dominant | Common | Rare |
| Package Management | Excellent | Improving | Good |
Popular Linux Distributions for Cybersecurity
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/sdais your hard drive,/dev/nullis 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, andFILE.TXTare 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
filecommand examines actual file type- Execute permissions matter more than
.exe
Getting Started with Linux
Option 1: Virtual Machine (Recommended for Beginners)
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:
Navigation:
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:
- Install Linux in a VM or WSL
- Navigate the filesystem using
cd,ls,pwd - Create a practice directory and make some test files
- Read man pages for commands you want to learn
- Update your system using the package manager
- 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:
- OverTheWire: Bandit - Learn Linux commands through challenges
- Linux Journey - Step-by-step tutorials
- Terminus - Game-based Linux 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:
- Linux Command Line Cheat Sheet
- Basic commands reference card (print and keep handy!)
Video Channels:
- NetworkChuck - Beginner-friendly Linux tutorials
- LearnLinuxTV - Comprehensive Linux courses
- The Cyber Mentor - Security-focused Linux content
Next Steps
- Next lesson: Learn about the Linux Kernel in detail
- Practice daily: Spend 30 minutes in the terminal each day
- Explore your system: Navigate directories, read man pages
- Try a challenge: Start the Bandit wargame on OverTheWire
- 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!)