Linux Commands for Hackers:Essential Commands Cheat Sheet β€” Neerajlovecyber

Β· linux  Β· 5 min read

Linux Commands for Hackers:Essential Commands Cheat Sheet

Linux Commands for Hackers: Your Essential Cheat Sheet. Perfect for cybersecurity beginners, CTF players, and ethical hackers. Master the terminal today!

Table of Contents

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

Terminal window
pwd

Shows your current location in the filesystem.

2. cd β€” Change Directory

Terminal window
cd /etc
cd .. # One level up
cd ~ # Home directory
cd - # Previous directory

3. ls β€” List Files and Directories

Terminal window
ls
ls -l # Long listing
ls -a # Show hidden files

4. cat β€” Show File Contents

Terminal window
cat file.txt

Use to read simple files like credentials or configs.

5. less β€” View Long Files

Terminal window
less bigfile.txt

Scroll up/down with arrow keys or space.

6. head / tail β€” View Start or End of Files

Terminal window
head /etc/passwd
tail /var/log/auth.log

7. touch β€” Create New File

Terminal window
touch notes.txt

8. mkdir β€” Make Directory

Terminal window
mkdir loot
mkdir -p recon/web/fuzz

9. cp β€” Copy Files and Folders

Terminal window
cp file.txt backup.txt
cp -r dir1 dir2

10. mv β€” Move or Rename

Terminal window
mv old.txt new.txt
mv file.txt /tmp/

11. rm β€” Remove Files or Directories

Terminal window
rm file.txt
rm -rf folder/

12. find β€” Locate Files

Terminal window
find / -name "*.conf" 2>/dev/null
find / -perm -4000 -type f 2>/dev/null # Find SUID binaries

13. grep β€” Search Inside Files

Terminal window
grep "admin" *.txt
grep -rin "password" /etc

14. nano / vi β€” Edit Text Files

Terminal window
nano config.txt
vi script.sh

15. chmod β€” Change Permissions

Terminal window
chmod +x exploit.sh
chmod 644 secrets.txt

16. chown β€” Change Ownership

Terminal window
chown user:group file.txt

17. ps β€” View Processes

Terminal window
ps aux
ps -ef | grep apache

18. top / htop β€” Monitor System Usage

Terminal window
top
htop # If installed

19. df β€” Check Disk Space

Terminal window
df -h

20. du β€” Check Folder Size

Terminal window
du -sh *

21. wget / curl β€” Download Files

Terminal window
wget http://example.com/file.sh
curl -O http://example.com/file.sh

22. sudo β€” Run as Root

Terminal window
sudo command

Check accessible commands:

Terminal window
sudo -l

23. id β€” Show Current User and Groups

Terminal window
id

24. whoami β€” Show Logged-In User

Terminal window
whoami

25. netstat / ss β€” Check Open Ports

Terminal window
netstat -tuln
ss -tuln

26. hostname / uname β€” System Info

Terminal window
hostname
uname -a

27. tar / zip β€” Archive or Extract

Terminal window
tar -czvf archive.tar.gz folder/
tar -xzvf archive.tar.gz
zip -r out.zip folder/
unzip out.zip

28. useradd / passwd β€” Add Users

Terminal window
sudo useradd hacker
sudo passwd hacker

29. usermod β€” Add User to Group

Terminal window
sudo usermod -aG sudo hacker

30. history β€” Show Past Commands

Terminal window
history

Download Printable Linux Commands Cheatsheet

Download the cheatsheet (PNG)

Linux Command-Line Cheatsheet for Hackers

Terminal window
==============================================================
Linux Cheatsheet for Hackers - Neerajlovecyber.com
==============================================================
====================[ SYSTEM & USER INFO ]====================
whoami β†’ Show current user
id β†’ Display UID, GID, groups
hostname β†’ Show system hostname
uname -a β†’ Kernel and system details
uptime β†’ System load and uptime
======================[ NAVIGATION ]==========================
pwd β†’ Show current directory
cd /path β†’ Change directory
cd .. β†’ Go up one level
cd - β†’ Previous directory
ls -alh β†’ List files (detailed, incl. hidden)
====================[ FILE MANAGEMENT ]=======================
touch file β†’ Create empty file
cp src dst β†’ Copy file or folder
mv old new β†’ Rename or move file/folder
rm file β†’ Delete file
rm -rf folder β†’ Force remove directory
mkdir name β†’ Create new directory
mkdir -p a/b/c β†’ Create nested directories
====================[ FILE CONTENT VIEWING ]==================
cat file β†’ Show entire file
less file β†’ Scroll through file
head file β†’ Show first 10 lines
tail file β†’ Show last 10 lines
tail -f logfile β†’ Live log monitoring
====================[ SEARCHING & FINDING ]===================
grep "text" file β†’ Search in file
grep -r "str" dir β†’ Recursive grep
find / -name "file" β†’ Find file by name
find / -perm -4000 β†’ Find SUID binaries (Privilege Esc)
locate keyword β†’ Fast file location (if installed)
======================[ PERMISSIONS ]=========================
ls -l β†’ Show file permissions
chmod +x file β†’ Make executable
chmod 755 file β†’ rwxr-xr-x
chown user:group f β†’ Change file owner
chmod -R 755 dir β†’ Recursively set permissions
======================[ NETWORKING ]==========================
ip a β†’ Show IP addresses
ping host β†’ Check connectivity
ss -tuln β†’ Show listening ports
netstat -tulnp β†’ Show all network connections
wget URL β†’ Download via HTTP
curl -O URL β†’ Download via curl
===================[ PROCESS MANAGEMENT ]=====================
ps aux β†’ List all running processes
top β†’ Live system monitor
htop β†’ Advanced process monitor (if installed)
kill PID β†’ Kill a process
killall name β†’ Kill process by name
===================[ ARCHIVING & COMPRESSION ]================
tar -czvf a.tar.gz f β†’ Compress folder to .tar.gz
tar -xzvf file.tar.gz→ Extract tar.gz file
zip -r out.zip dir β†’ Create zip file
unzip file.zip β†’ Extract zip file
====================[ PACKAGE MANAGEMENT ]====================
apt update β†’ Update package index (Debian/Ubuntu)
apt install pkg β†’ Install a package
apt remove pkg β†’ Remove a package
dnf install pkg β†’ Install on Fedora/RHEL
dnf remove pkg β†’ Remove from Fedora/RHEL
====================[ PRIVILEGE ESCALATION ]==================
sudo command β†’ Run as root
sudo -l β†’ Show allowed sudo commands
find / -perm -4000 β†’ Find SUID binaries
cat /etc/passwd β†’ View user accounts
cat /etc/shadow β†’ Encrypted passwords (root access needed)
======================[ MISC & UTILITIES ]=====================
history β†’ Show recent commands
clear β†’ Clear the terminal
echo $VAR β†’ Print variable
export VAR=value β†’ Set environment variable
alias 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.

Back to Blog

Related Posts

View All Posts Β»
Steganography Cheatsheet for CTF Beginners

Steganography Cheatsheet for CTF Beginners

A complete Steganography 101 CTF Cheatsheet covering essential tools, techniques, and tips to solve image, audio, and file-based stego challenges. Perfect for beginners and CTF players looking to master hidden data analysis.