
Every good hacker is comfortable in the Linux terminal. Not because it looks cool in movies, but because Linux gives you total control over a machine, and almost every hacking tool is built to run from the command line. If you want to work in ethical hacking, penetration testing, or bug bounty, learning Linux commands is not optional. It is step one.
The good news? You do not need to memorize hundreds of commands. You need maybe forty, and this guide covers the ones that actually matter. We will keep it simple, explain what each command does in plain English, and show real examples you can try in a safe lab like Kali Linux.
Quick reminder before we start: use these skills only on systems you own or have permission to test. Learning to hack is legal. Hacking without permission is not.
Before the commands, it helps to know why Linux is the hacker's home. Linux is free, open source, and endlessly customizable. It runs the servers that power most of the internet, so understanding it means understanding your targets. Most importantly, security tools like Nmap, Metasploit, Wireshark, and John the Ripper are made for Linux first. Kali Linux, the most popular hacking operating system, comes with hundreds of these tools already installed.
The terminal is where all of this lives. So let us learn to speak its language.
The first thing you do on any machine is figure out where you are and what is around you. These commands are your eyes.
| Command | What It Does |
|---|---|
pwd | Shows your current folder (print working directory) |
ls | Lists files and folders |
ls -la | Lists everything, including hidden files and details |
cd <folder> | Moves into a folder |
cd .. | Moves up one folder |
cd ~ | Jumps to your home folder |
clear | Cleans up a messy screen |
Try this simple flow. It is the first thing most testers do on a new system:
pwd # Where am I?
ls -la # What's here, including hidden stuff?
cd /etc # Move to a folder worth exploring
Hidden files matter a lot in hacking. They often store passwords, configuration, and secrets. That is why ls -la (which shows files starting with a dot) is a habit worth building early.
Once you find interesting files, you need to open and search them. This is where a lot of the real discovery happens, because passwords and keys are often sitting in plain text.
| Command | What It Does |
|---|---|
cat <file> | Prints a whole file to the screen |
less <file> | Opens a file you can scroll through |
head <file> | Shows the first lines of a file |
tail <file> | Shows the last lines of a file |
nano <file> | Opens a simple text editor |
cp <a> <b> | Copies a file |
mv <a> <b> | Moves or renames a file |
rm <file> | Deletes a file |
A classic move for testers is reading the file that lists all user accounts on a Linux system:
cat /etc/passwd # See every user account on the machine
This is where beginners level up into real testers. On a big system, you cannot open every file by hand. You search. Two commands do the heavy lifting: find locates files, and grep searches inside them.
# Find every file named "config" on the system
find / -name "config*" 2>/dev/null
# Search a file for the word "password"
grep "password" config.php
# Search many files at once for anything that looks like a key
grep -r "api_key" /var/www/ 2>/dev/null
That 2>/dev/null at the end just hides error messages so your screen stays clean. The -r in grep means "search everything in this folder and below." These two commands alone will uncover leaked passwords, API keys, and hidden notes on a surprising number of machines.
Linux controls who can read, write, and run files using permissions. Understanding them is huge for hacking, because misconfigured permissions are one of the most common ways attackers gain more control.
| Command | What It Does |
|---|---|
ls -l | Shows permissions for each file |
chmod <perms> <file> | Changes a file's permissions |
chown <user> <file> | Changes who owns a file |
whoami | Shows your current username |
id | Shows your user and group IDs |
sudo <command> | Runs a command as the powerful root user |
One of the most valuable hacking searches on all of Linux is finding files that run with root power. These are called SUID files, and finding a weak one can turn a normal user into an admin:
# Find files that run with elevated privileges
find / -perm -u=s -type f 2>/dev/null
This single command is a core step in something called privilege escalation, which is how attackers go from "I have basic access" to "I control the whole machine."
Knowing who is on a system, and who has power, is basic reconnaissance.
| Command | What It Does |
|---|---|
whoami | Your current user |
who | Who else is logged in right now |
id <user> | A user's groups and permissions |
cat /etc/passwd | List of all accounts |
sudo -l | What powerful commands you are allowed to run |
su <user> | Switch to another user |
The command sudo -l deserves special attention. It shows exactly which admin commands your account is permitted to run, and testers check it immediately because it often reveals an easy path to full control.
Hacking is often about networks. These commands help you understand a machine's connections, its address, and what it is talking to.
| Command | What It Does |
|---|---|
ifconfig or ip a | Shows your machine's IP address |
ping <ip> | Checks if another machine is alive |
netstat -tulnp | Shows open ports and running network services |
ss -tulnp | A faster, modern version of netstat |
curl <url> | Fetches a web page or API from the terminal |
wget <url> | Downloads a file from the internet |
Checking what ports are open on your own machine is a great habit, because open ports are doorways, and every doorway is something to secure or investigate:
ss -tulnp # What services are listening on this machine?
Sometimes you need to see what is running, or stop something. These process commands handle that.
| Command | What It Does |
|---|---|
ps aux | Lists every running program |
top | A live, updating view of running programs |
kill <pid> | Stops a program by its ID number |
jobs | Shows background tasks |
bg / fg | Sends tasks to background or foreground |
Looking at running processes with ps aux often reveals services, scripts, and even passwords passed on the command line, which is why it is a standard step during any assessment.
You will constantly grab tools and scripts. On Kali and Debian-based systems, these commands install and update software.
# Update your list of available software
sudo apt update
# Install a tool, for example nmap
sudo apt install nmap
# Download a script directly from the internet
wget https://example.com/script.sh
Here is what separates people who know commands from people who are fluent. You can connect commands with the pipe symbol |, sending the output of one command straight into another. This is where the terminal becomes a superpower.
# Find every user account, then filter for ones that can log in with a shell
cat /etc/passwd | grep "/bin/bash"
# List all processes, then search for anything related to apache
ps aux | grep apache
# Count how many files are in a folder
ls | wc -l
Learning to chain commands with pipes is the single biggest jump in Linux skill you can make. It turns simple tools into custom, on-the-spot solutions.
Save this. It is the whole guide in one place.
| Category | Command | Purpose |
|---|---|---|
| Navigation | pwd | Show current folder |
| Navigation | ls -la | List all files including hidden |
| Navigation | cd <dir> | Change folder |
| Files | cat <file> | Read a file |
| Files | nano <file> | Edit a file |
| Search | find / -name "x" | Find files by name |
| Search | grep -r "x" . | Search inside files |
| Permissions | chmod, chown | Change permissions/owner |
| Permissions | find / -perm -u=s -type f | Find SUID files |
| Users | whoami, id, sudo -l | Check who you are and your power |
| Network | ip a, ping, ss -tulnp | Check IP, connectivity, open ports |
| Network | curl, wget | Fetch or download from the web |
| Processes | ps aux, top, kill | View and stop programs |
| Software | sudo apt install <tool> | Install tools |
| Power | command1 | command2 | Chain commands with a pipe |
Do not try to memorize this list in one sitting. Nobody learns Linux that way. Instead, spin up Kali Linux in a free virtual machine, open the terminal, and actually type these commands. Break things. Explore. The muscle memory builds fast once your hands are on the keyboard.
Focus first on navigation, then file reading, then grep and find, then permissions. Those four skills alone will carry you through most beginner hacking labs and capture-the-flag challenges. Everything else you will pick up naturally as you go.
The terminal feels intimidating on day one and feels like home by day thirty. Start today, stay consistent, and always practice on systems you are allowed to touch.
Reminder: These commands are for learning and for authorized testing only. Never access systems without permission.
Comments (0)
No comments yet. Be the first to share your thoughts.