Linux Commands
Linux command‑line tools are the backbone of reconnaissance, exploitation, and post‑exploitation on Unix‑like systems.
Common Commands
Navigation & File Management
Command |
Description |
Usage
|
pwd |
Print working directory |
pwd [OPTIONS]
|
cd |
Change directory |
cd [DIRECTORY]
|
ls |
List directory contents |
ls [OPTIONS] [FILE...]
|
mkdir |
Create directory |
mkdir [OPTIONS] DIRECTORY
|
rmdir |
Remove empty directory |
rmdir DIRECTORY
|
cp |
Copy files or directories |
cp SOURCE DEST
|
mv |
Move or rename files/directories |
mv SOURCE DEST
|
rm |
Delete files or directories |
rm [OPTIONS] FILE...
|
touch |
Create empty file or update timestamp |
touch FILENAME
|
ln |
Create hard or symbolic links |
ln [OPTIONS] TARGET LINK_NAME
|
find |
Search for files and directories |
find [PATH] [OPTIONS] [EXPRESSION]
|
chmod |
Change file permissions |
chmod [OPTIONS] MODE FILE
|
chown |
Change file ownership (user) |
chown [OPTIONS] USER FILE
|
chgrp |
Change group ownership |
chgrp [OPTIONS] GROUP FILE
|
umask |
Set default file permission mask |
umask [MASK]
|
tar |
Archive files into tarball |
tar -czf ARCHIVE.tar.gz FILES
|
gzip |
Compress files using Gzip |
gzip FILE
|
zip |
Compress files into ZIP archive |
zip ARCHIVE.zip FILES
|
Viewing & Text Processing
Command |
Description |
Usage
|
cat |
Concatenate & display files |
cat [OPTIONS] FILE...
|
less |
Paginate large files |
less FILE
|
head |
Show first lines of a file |
head [OPTIONS] FILE
|
tail |
Show last lines / follow file |
tail [OPTIONS] FILE
|
grep |
Search for patterns |
grep [OPTIONS] PATTERN FILE
|
System & User Info
Command |
Description |
Usage
|
whoami |
Show current user |
whoami
|
id |
Display user/group IDs |
id [USERNAME]
|
df |
Disk usage overview |
df [OPTIONS]
|
du |
Show disk usage for files/directories |
du [OPTIONS] [PATH]
|
uptime |
Show how long the system has been running |
uptime
|
uname |
System information (kernel, OS, architecture) |
uname -a
|
hostname |
Show or set system hostname |
hostname
|
date |
Display or set system date/time |
date
|
cal |
Display a calendar |
cal
|
env |
Show environment variables |
env
|
set |
Display shell variables and functions |
set
|
history |
List previously executed commands |
history
|
ps |
Display running processes |
ps aux
|
top |
Real-time system process monitor |
top
|
kill |
Terminate process by PID |
kill [-9] PID
|
pkill |
Kill processes by name |
pkill PROCESS_NAME
|
pgrep |
Search for processes by name |
pgrep PROCESS_NAME
|
w |
Show who is logged in and what they are doing |
w
|
who |
Show who is logged in |
who
|
last |
Show login history |
last
|
free |
Show memory usage |
free -h
|
Networking
Command |
Description |
Usage
|
ping |
Test network connectivity (ICMP) |
ping [OPTIONS] DESTINATION
|
curl |
Retrieve data from URLs / APIs |
curl [OPTIONS] URL
|
ssh |
Secure remote shell & tunnelling |
ssh [OPTIONS] USER@HOST
|
Help & Documentation
Command |
Description |
Usage
|
man |
Read manual pages |
man COMMAND
|
echo |
Display text / variables |
echo [STRING]
|
|}
Examples
Print Working Directory
↑ Commands
Change Directory
↑ Commands
List All Files (long + hidden)
↑ Commands
Create Directory
↑ Commands
Remove Empty Directory
↑ Commands
Copy File
cp secrets.txt /tmp/secrets.bak
↑ Commands
Move & Rename
mv old.log archive/old.log
↑ Commands
Force‑Delete Directory
↑ Commands
Show File Contents
cat /etc/passwd | grep ":/bin/bash"
↑ Commands
View Large Log
↑ Commands
First 10 Lines
↑ Commands
Follow File Growth
tail -f /var/log/nginx/access.log
↑ Commands
Search Pattern
↑ Commands
Current User
↑ Commands
User & Group IDs
↑ Commands
Human‑Readable Disk Usage
↑ Commands
Show Last 20 Commands
↑ Commands
Ping Host 4 Times
↑ Commands
Download Web Page
curl -o index.html http://example.com
↑ Commands
SSH on Custom Port
↑ Commands
Read Manual Page
↑ Commands
Write to File
echo \"hacked\" > /tmp/proof.txt
↑ Commands
See Also