Kali Linux Commands Cheat Sheet: Complete Quick Reference

This cheat sheet covers the essential Kali Linux commands every pentester and ethical hacker uses daily. It is organized by task so you can find what you need fast from navigating the file system to running your first nmap scan. Whether you’re a beginner setting up your first lab or a working professional on an engagement, keep this page bookmarked.

Tip: Bookmark this page. Come back whenever you need a fast Kali Linux command reference.

File and Directory Operations

CommandWhat It Does
lsList files in the current directory
ls -laList all files including hidden ones, with permissions and ownership
pwdPrint the current working directory
cd /path/to/dirChange to a specific directory
cd ..Move one directory up
mkdir dirnameCreate a new directory
mkdir -p dir/sub/subCreate nested directories in one command
rm filenameDelete a file
rm -rf dirnameDelete a directory and all its contents
cp file1 file2Copy a file
mv file1 file2Move or rename a file
touch filenameCreate an empty file or update its timestamp
find / -name "*.conf"Search for files by name from root
locate filenameFast file search using a pre-built index

Pentesting tip: ls -la reveals hidden files (starting with .) and SUID bits. During post-exploitation, this is the first command you run to look for misconfigurations.

File Viewing and Editing

CommandWhat It Does
cat filePrint file contents to the terminal
cat /etc/passwdRead the password file — lists all users
less fileView a file page by page (use q to quit)
head -n 20 fileShow the first 20 lines of a file
tail -n 20 fileShow the last 20 lines of a file
tail -f /var/log/auth.logFollow a log file in real time
grep "root" /etc/passwdSearch for a pattern inside a file
grep -r "password" /etc/Recursively search for a string in a directory
nano filenameOpen a file in the nano text editor
vim filenameOpen a file in Vim
diff file1 file2Compare two files line by line
strings fileExtract printable strings from a binary file
xxd fileView file in hex dump format

Pentesting tip: strings and xxd are your first tools when you pick up an unknown binary in a CTF. tail -f is how you watch logs in real time during an active engagement.

File Permissions and Ownership

CommandWhat It Does
chmod 755 fileSet permissions (rwxr-xr-x) using numeric notation
chmod +x script.shMake a file executable
chmod -R 644 /var/www/Recursively set permissions on a directory
chown user:group fileChange the owner and group of a file
chown -R www-data /var/wwwRecursively change ownership
lsattr fileView special file attributes
chattr +i fileMake a file immutable — not even root can delete it
chattr +a fileSet append-only — useful for protecting log files
find / -perm -4000 2>/dev/nullFind all SUID binaries on the system
find / -perm -2000 2>/dev/nullFind all SGID binaries
find / -writable -type f 2>/dev/nullFind world-writable files

Pentesting tip: find / -perm -4000 is one of the most important privilege escalation checks. SUID binaries run as their owner, not the person executing them. Learn more about protecting files with the chattr command.

Process Management

CommandWhat It Does
ps auxList all running processes with details
ps aux | grep apacheFilter processes by name
topInteractive real-time process viewer
htopBetter interactive process viewer
kill 1234Send SIGTERM to process ID 1234
kill -9 1234Force kill a process (SIGKILL)
pkill nginxKill all processes matching the name
jobsList background jobs in the current shell
bg %1Resume job 1 in the background
fg %1Bring job 1 back to the foreground
nohup command &Run a command that survives terminal close
pgrep sshdGet the PID of a running process by name

Pentesting tip: ps aux is the first thing you run after getting a shell to understand what’s running on the machine. nohup keeps your tools running even if your connection drops.

User and Group Management

CommandWhat It Does
whoamiPrint the current user’s name
idShow current user’s UID, GID, and all groups
whoShow who is currently logged in
wShow who is logged in and what they are doing
lastShow recent login history
useradd -m usernameCreate a new user with a home directory
passwd usernameSet or change a user’s password
usermod -aG sudo usernameAdd a user to the sudo group
userdel -r usernameDelete a user and their home directory
su - usernameSwitch to another user (with their environment)
sudo -lList commands the current user can run as sudo
cat /etc/passwdView all users on the system
cat /etc/shadowView hashed passwords (requires root)

Pentesting tip: sudo -l is a critical privilege escalation check. A surprising number of systems allow users to run commands as root without a password. The id command tells you immediately if you’re already in a privileged group.

Networking Commands

CommandWhat It Does
ip aShow all network interfaces and IP addresses
ip routeShow the routing table
ping -c 4 8.8.8.8Send 4 ICMP packets to test connectivity
netstat -tulnpShow all listening TCP/UDP ports and their processes
ss -tulnpFaster alternative to netstat
curl https://example.comFetch a URL from the terminal
wget https://example.com/fileDownload a file
dig kalilinuxtutorials.comPerform a DNS lookup
traceroute domain.comTrace the route packets take to a host
arp -aShow the ARP table (local network neighbors)
nc -lvnp 4444Start a netcat listener on port 4444
ssh user@hostConnect to a remote host via SSH

Pentesting tip: ss -tulnp gives you a fast picture of all listening services after you land a shell. For active scanning, our nmap guide covers everything from SYN scans to NSE scripts.

System Information

CommandWhat It Does
uname -aPrint all system information (kernel, arch, OS)
uname -rPrint only the kernel version
hostnamectlShow hostname, OS, kernel, and architecture
uptimeShow how long the system has been running
free -hShow RAM and swap usage in human-readable format
df -hShow disk usage per filesystem
du -sh /var/log/Show size of a specific directory
lsblkList block devices and partitions
cat /etc/os-releaseShow OS name and version
cat /proc/versionShow kernel version from the proc filesystem

Pentesting tip: uname -r tells you the kernel version, which you cross-reference against known kernel exploits. Check the full uname command guide for every available flag.

Security-Specific Kali Linux Commands

CommandWhat It Does
nmap -sV -sC targetRun a version and default script scan
nmap -p- targetScan all 65535 ports
nmap -O targetAttempt OS detection
nc -lvnp 4444Open a reverse shell listener
python3 -c 'import pty; pty.spawn("/bin/bash")'Upgrade a basic shell to a TTY
ufw statusCheck the firewall status
ssh-keygen -t rsa -b 4096Generate an RSA key pair
john hash.txt --wordlist=/usr/share/wordlists/rockyou.txtCrack a hash with John the Ripper
hydra -l user -P rockyou.txt ssh://targetBrute force SSH credentials
searchsploit apache 2.4Search ExploitDB for Apache exploits
msfconsoleLaunch the Metasploit Framework

Pentesting tip: The Python3 PTY upgrade is essential after catching a reverse shell. A raw shell has no tab completion and no arrow keys. After spawning the PTY, press Ctrl+Z, run stty raw -echo; fg, then export TERM=xterm to get a fully interactive shell.

Quick Reference Summary

TaskCommand
Find SUID binariesfind / -perm -4000 2>/dev/null
Check sudo permissionssudo -l
List all open portsss -tulnp
Get current user and groupsid
Check kernel versionuname -r
Upgrade shell to TTYpython3 -c 'import pty; pty.spawn("/bin/bash")'
Start a netcat listenernc -lvnp 4444
Scan a target with nmapnmap -sV -sC target
Find writable directoriesfind / -writable -type d 2>/dev/null
Download a filewget https://url/file
Extract a tar.gz archivetar -xzvf archive.tar.gz
Install a toolapt install toolname
Search exploit databasesearchsploit keyword

This cheat sheet covers the commands you will actually use — in the terminal, on engagements, and in CTF competitions. Save it and come back whenever you need a quick lookup. Got a command that should be here? Drop it in the comments below.