Show Menu

White Hat Commands in Linux Cheat Sheet by

Some basic commands used in Linux for white hat/ethical hacking purposes, as well as just some good general knowledge in linux with networking.

General Navigation and Bash Commands

Show current directory
mkdir directory
Make directory directory
rmdir directory
Remove directory
cd directory
Change to directory directory
cd ..
Go up a directory (the parent directory)
Change to home directory
list files (in current directory)
cat file
Display contents of file
ls directory
list files in specified directory
Show your username
uname -a
Show system and kernel
head -n1 /etc/issue
Show distro­bution
man command
Show manual­/in­for­mation for specified command
Show uptime
Show system date
Show mounted file systems

ls Options

Show all plus hidden files
Recursive list
Reverse order
Sort by last modified
Sort by file size
Long listing format
One file per line
Comma-­sep­arated output
Quoted output


grep option string files
Search for string in files
Case insens­itive search
Recursive search
Inverted search
Print count of matching lines
Show matched part of file only

More Search Commands

find /dir/ -name name
Find files starting with name in dir
find /dir/ -user name
Find files owned by name in dir
whereis command
Find binary source manual for command
locate file
Find file with quick search of system index
which file
Shows path to file
Add 2>/­dev­/null at the end to discard error messages

File Manipu­lation

Create, change, modify timestamps of a file
Print specified text
Move source to directory; Rename Old to New
Remove files or direct­ories
rm -f
Ignore nonexi­stent files
rm -i
Prompt before every removal
rm -I
Prompt once before removing more than 3 files
rm -r
Remove direct­ories and their contents recurs­ively
cp file1 file2
Copy file1 to file2
cp -b
Backup (doesn't support argument)
cp -f
If file cannot be opened remove and try again
cp -l
Hard link files instead of copying
cp -n
Do not overwrite existing file
cp -s
Make symbolic link instead of copying
cp -r
Copy direct­ories recurs­ively
cp -u
Copy only when SOURCE file is newer than destin­ation file or when destin­ation file is missing

Permis­sions (chmod)

chmod u file
Change owner permission of file
chmod g file
Change group permission of file
chmod o file
Change all others' permission of file
chmod a file
Change everyone's permission of file
permission to read symbol
permission to write symbol
permission to execute symbol
chmod o+r file
Adds the "­rea­d" ability to "­oth­er" users
chmod o-r file
Removes the "­rea­d" ability from "­oth­er" users
chmod 777 file
Adds rwx permis­sions to all users using octal notations
I advise looking up an octal notations table/­exp­lai­nation for any help unders­tanding the numbers and their placement, this is just for a quick reference.

Ownership (chown)

chown newowner file
Change user owner of file to newowner
chown :groupname file.txt
Change group owner of file.txt to groupname
chown newowner:groupname file.txt
Change user owner and group owner of file
Suppress most error messages
Make changes recurs­ively
If cmd argument is symbolic link, traverse it
Traverse every symbolic link to a directory encoun­tered
Affect each symbolic link instead of any referenced file
Make note of the :


Show snapshot of current processes
Show realtime processes
kill pid
Kill process with ID pid
pkill name
Kill process with name name
killall name
Kill all process with names beginning with name

Basic Networking Commands

Show details of Network settings (IP, version, etc)
Shows site owner and DNS name server
Shows namese­rvers and IP Addresses
Shows routing inform­ation to host
Port scanning (TCP, UDP)
Send ICMP pings; Also checks latency
Show/m­ani­pulate IP routing table
Show/m­ani­pulate ARP cache
See ARP cache, neighbor table, add routes
Show various network info
Capture network traffic
dig website
Show various IP inform­ation

Netcat (nc)

nc host port
Connect to remote server(s)
nc -l IPaddress port
Listen mode; listen for incoming connec­tions
Specify port number
Verbose mode
Scan for open ports
Specify delay before closing connection
Source­-ro­uting hop point(s) up to 8
Numeri­c-only IP addresses
-s address
local source address
-c string
specify shell cmds to execute after connect
-e filename
Specify filename to execute after connect (if no working /bin/sh)


Print in ASCII
-c count
Exit after capturing count packets
Show available interfaces
Print link-level header on each line
-F file
Use file as filter expression
List data link types for interface
Don't convert addresses to names
Don't capture in promis­cuous mode
Quick Output
-r file
Read packets from file
-s len
Capture up to len bytes per packet
Print absolute TCP seq numbers
Don't print timestamps
-w file
Write captured packets to file
-y type
Specify data-link type
-Z user
Drop privileges from root to user


No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Enumeration Cheat Sheet