Β· linux Β· 5 min read
Linux Commands for Hackers:Essential Commands Cheat Sheet

Table of Contents
- 1.Why Hackers Need the Terminal
- 2.Essential Linux Commands for Hackers
- 2.11. pwd β Print Working Directory
- 2.22. cd β Change Directory
- 2.33. ls β List Files and Directories
- 2.44. cat β Show File Contents
- 2.55. less β View Long Files
- 2.66. head / tail β View Start or End of Files
- 2.77. touch β Create New File
- 2.88. mkdir β Make Directory
- 2.99. cp β Copy Files and Folders
- 2.1010. mv β Move or Rename
- 2.1111. rm β Remove Files or Directories
- 2.1212. find β Locate Files
- 2.1313. grep β Search Inside Files
- 2.1414. nano / vi β Edit Text Files
- 2.1515. chmod β Change Permissions
- 2.1616. chown β Change Ownership
- 2.1717. ps β View Processes
- 2.1818. top / htop β Monitor System Usage
- 2.1919. df β Check Disk Space
- 2.2020. du β Check Folder Size
- 2.2121. wget / curl β Download Files
- 2.2222. sudo β Run as Root
- 2.2323. id β Show Current User and Groups
- 2.2424. whoami β Show Logged-In User
- 2.2525. netstat / ss β Check Open Ports
- 2.2626. hostname / uname β System Info
- 2.2727. tar / zip β Archive or Extract
- 2.2828. useradd / passwd β Add Users
- 2.2929. usermod β Add User to Group
- 2.3030. history β Show Past Commands
- 3.Download Printable Linux Commands Cheatsheet
- 4.Linux Command-Line Cheatsheet for Hackers
- 5.Final Thoughts
If youβre learning ethical hacking, Linux is your battlefield. Most CTF labs, real-world targets, and cybersecurity tools are Linux-based β and the command line is your weapon.
This guide is for beginners coming from Windows or GUI-heavy environments who want to become comfortable with the Linux shell. Below, youβll find 25+ practical commands, explained clearly, followed by a print-ready cheatsheet.
Why Hackers Need the Terminal
Most hacking tools (Nmap, Netcat, Metasploit) run on Linux.
You often get access to targets via shell or SSH, not GUI.
Privilege escalation, file enumeration, and tool installation are faster through the terminal.
In real-world systems, the GUI is often disabled or unavailable.
Essential Linux Commands for Hackers
1. pwd
β Print Working Directory
pwd
Shows your current location in the filesystem.
2. cd
β Change Directory
cd /etccd .. # One level upcd ~ # Home directorycd - # Previous directory
3. ls
β List Files and Directories
lsls -l # Long listingls -a # Show hidden files
4. cat
β Show File Contents
cat file.txt
Use to read simple files like credentials or configs.
5. less
β View Long Files
less bigfile.txt
Scroll up/down with arrow keys or space.
6. head
/ tail
β View Start or End of Files
head /etc/passwdtail /var/log/auth.log
7. touch
β Create New File
touch notes.txt
8. mkdir
β Make Directory
mkdir lootmkdir -p recon/web/fuzz
9. cp
β Copy Files and Folders
cp file.txt backup.txtcp -r dir1 dir2
10. mv
β Move or Rename
mv old.txt new.txtmv file.txt /tmp/
11. rm
β Remove Files or Directories
rm file.txtrm -rf folder/
12. find
β Locate Files
find / -name "*.conf" 2>/dev/nullfind / -perm -4000 -type f 2>/dev/null # Find SUID binaries
13. grep
β Search Inside Files
grep "admin" *.txtgrep -rin "password" /etc
14. nano
/ vi
β Edit Text Files
nano config.txtvi script.sh
15. chmod
β Change Permissions
chmod +x exploit.shchmod 644 secrets.txt
16. chown
β Change Ownership
chown user:group file.txt
17. ps
β View Processes
ps auxps -ef | grep apache
18. top
/ htop
β Monitor System Usage
tophtop # If installed
19. df
β Check Disk Space
df -h
20. du
β Check Folder Size
du -sh *
21. wget
/ curl
β Download Files
wget http://example.com/file.shcurl -O http://example.com/file.sh
22. sudo
β Run as Root
sudo command
Check accessible commands:
sudo -l
23. id
β Show Current User and Groups
id
24. whoami
β Show Logged-In User
whoami
25. netstat
/ ss
β Check Open Ports
netstat -tulnss -tuln
26. hostname
/ uname
β System Info
hostnameuname -a
27. tar
/ zip
β Archive or Extract
tar -czvf archive.tar.gz folder/tar -xzvf archive.tar.gzzip -r out.zip folder/unzip out.zip
28. useradd
/ passwd
β Add Users
sudo useradd hackersudo passwd hacker
29. usermod
β Add User to Group
sudo usermod -aG sudo hacker
30. history
β Show Past Commands
history
Download Printable Linux Commands Cheatsheet
Linux Command-Line Cheatsheet for Hackers
==============================================================Linux Cheatsheet for Hackers - Neerajlovecyber.com==============================================================
====================[ SYSTEM & USER INFO ]====================whoami β Show current userid β Display UID, GID, groupshostname β Show system hostnameuname -a β Kernel and system detailsuptime β System load and uptime
======================[ NAVIGATION ]==========================pwd β Show current directorycd /path β Change directorycd .. β Go up one levelcd - β Previous directoryls -alh β List files (detailed, incl. hidden)
====================[ FILE MANAGEMENT ]=======================touch file β Create empty filecp src dst β Copy file or foldermv old new β Rename or move file/folderrm file β Delete filerm -rf folder β Force remove directorymkdir name β Create new directorymkdir -p a/b/c β Create nested directories
====================[ FILE CONTENT VIEWING ]==================cat file β Show entire fileless file β Scroll through filehead file β Show first 10 linestail file β Show last 10 linestail -f logfile β Live log monitoring
====================[ SEARCHING & FINDING ]===================grep "text" file β Search in filegrep -r "str" dir β Recursive grepfind / -name "file" β Find file by namefind / -perm -4000 β Find SUID binaries (Privilege Esc)locate keyword β Fast file location (if installed)
======================[ PERMISSIONS ]=========================ls -l β Show file permissionschmod +x file β Make executablechmod 755 file β rwxr-xr-xchown user:group f β Change file ownerchmod -R 755 dir β Recursively set permissions
======================[ NETWORKING ]==========================ip a β Show IP addressesping host β Check connectivityss -tuln β Show listening portsnetstat -tulnp β Show all network connectionswget URL β Download via HTTPcurl -O URL β Download via curl
===================[ PROCESS MANAGEMENT ]=====================ps aux β List all running processestop β Live system monitorhtop β Advanced process monitor (if installed)kill PID β Kill a processkillall name β Kill process by name
===================[ ARCHIVING & COMPRESSION ]================tar -czvf a.tar.gz f β Compress folder to .tar.gztar -xzvf file.tar.gzβ Extract tar.gz filezip -r out.zip dir β Create zip fileunzip file.zip β Extract zip file
====================[ PACKAGE MANAGEMENT ]====================apt update β Update package index (Debian/Ubuntu)apt install pkg β Install a packageapt remove pkg β Remove a packagednf install pkg β Install on Fedora/RHELdnf remove pkg β Remove from Fedora/RHEL
====================[ PRIVILEGE ESCALATION ]==================sudo command β Run as rootsudo -l β Show allowed sudo commandsfind / -perm -4000 β Find SUID binariescat /etc/passwd β View user accountscat /etc/shadow β Encrypted passwords (root access needed)
======================[ MISC & UTILITIES ]=====================history β Show recent commandsclear β Clear the terminalecho $VAR β Print variableexport VAR=value β Set environment variablealias ll='ls -alh' β Define command alias
Final Thoughts
These Linux commands are foundational for hackers and cybersecurity learners. Youβll use them to:
Navigate and explore compromised systems
Investigate misconfigurations
Upload payloads
View logs and credentials
Escalate privileges
Manage tools and scripts
Practice regularly in platforms like TryHackMe, HackTheBox, or your own Kali/Parrot VM.