LINUX Cheat Sheet
LINUX Cheat Sheet
ps: Show snapshot of processes arp: Display the ARP table of the device
top: Show real-time processes arpwatch: Display Ethernet activity and Ethernet/IP pairings
kill pid: Kill the process with ID pid bmon: Display bandwidth captures
ULTIMATE LINUX CHEAT SHEET pkill name: Kill processes with the name name
killall name: Kill all processes with names starting with name
curl: Used for file transfer
dhclient: Analyze clients' IP address, subnet mask, gateway, DNS server
program &: Start program in the background dig: Used for simple DNS lookup
bg: List and resume stopped jobs in the background dstat: Collect and show system resources
System Information Commands
fg: Bring the most recent background job to the foreground ethtool: Check settings of your NIC
uname -a: Show system and kernel information
fg x: Bring job x to the foreground ftp: Used for file transfer
head -n1 /etc/issue: Show distribution information
nice: Start a process with a given priority host: Used for DNS lookup
mount: Show mounted filesystems
renice: Change the priority of an already running process hping3: Used for packet analysis
date: Show system date
pstree: Display processes in a tree-like diagram ifconfig: Monitor and configure network interfaces
uptime: Show uptime
pmap: Display a memory usage map of processes ip address: Check network interfaces and routing activities
whoami: Show your username
lsof: List files opened by running processes iptables: Used for IP packet filtering
man command: Show manual for the command
iftop: Display current bandwidth usage
ifup: Enable interfaces
ifdown: Disable interfaces
Bash Shortcuts File Operations iwconfig: Monitor and configure wireless interfaces
CTRL-c: Stop current command touch file1: Create file1 nload: Used as a bandwidth monitoring tool
CTRL-z: Sleep program cat file1 file2: Concatenate files and output nmap: Used for security audits
CTRL-a: Go to the start of the line less file1: View and paginate file1 nslookup: Used for DNS queries
CTRL-e: Go to the end of the line file file1: Get the type of file1 ip route: Routing table management
CTRL-u: Cut from the start of the line cp file1 file2: Copy file1 to file2 netstat: Check network connections
CTRL-k: Cut to the end of the line mv file1 file2: Move file1 to file2 route: Display and manipulate IP routing table
CTRL-r: Search history rm file1: Delete file1 ping: Check reachability
!!: Repeat the last command head file1: Show the first 10 lines of file1 sftp: Secure file transfer
!abc: Run the last command starting with "abc” tail file1: Show the last 10 lines of file1 ss: Give detailed information about the sockets
!abc:p: Print the last command starting with "abc" tail -F file1: Output the last lines of file1 as it changes ssh: Used for secure connections
!$: Last argument of the previous command scp: Secure file transfer
ALT-.: Last argument of the previous command tcpdump: Used for analyzing and capturing
!*: All arguments of the previous command lFile Permissions telnet: Used for classical unsecured connections
^abc^123: Run the previous command, replacing "abc" with "123" chmod 775 file: Change the mode of file to 775 tshark: Used for packet analysis and capturing
chmod -R 600 folder: Recursively change the mode of folder to 600 traceroute: Used for path tracking
chownuser:group file: Change the owner of file to user and the w: Show who is logged in and what they do
group to group wget: Used to download content from web servers
IO Redirection
whois: Check the WHOIS database and return IP and domain info
cmd< file: Input of cmd from file
cmd1 <(cmd2): Output of cmd2 as file input to cmd1
Directory Operations
10001011000010100010011000
cmd> file: Standard output (stdout) of cmd to file
pwd: Show current directory 11100000001010110001001001
cmd> /dev/null: Discard stdout of cad Help Commands
cmd>> file: Append stdout to file mkdirdir: Create directory dir 10001011000010100100101101 command -h or command --help: Review all available options of the command
cmd 2> file: Error output (stderr) of cmd to file cd dir: Change directory to dir 00101100000101000110011000 info command: Find info documents about the command
cd ..: Go up a directory
cmd 1>&2: Stdout to the same place as stderr 10111000000010010000110111 whatis command: Display a single-line description about the command
ls: List files
cmd 2>&1: Stderr to the same place as stdout 00001000000100100010001010 man UNIXCOMMAND: View the detailed man page of the command
cmd&> file: Every output of cmd to file apropos: Search man pages for available commands on specific functionality
Search Files
grep pattern files: Search for pattern in files
Pipes grep -i pattern files: Case-insensitive search Hardware Information Commands
cmd1 | cmd2: Stdout of cmd1 to cmd2 grep -r pattern dir: Recursive search in dir dmesg: Display messages in the kernel ring buffer
cmd1 |& cmd2: Stderr of cmd1 to cmd2 grep -v pattern files: Inverted search cat /proc/cpuinfo: Display CPU information
grep -o pattern files: Show matched part of the file only cat /proc/meminfo: Display memory information
find /dir/ -name name*: Find files starting with name in dir lspci -tv: Display PCI devices
Command Lists find /dir/ -user name: Find files owned by name in dir lsusb -tv: Display USB devices
cmd1 ; cmd2: Run cmd1 then cmd2 find /dir/ -mmin num: Find files mofdified less than num minutes ago in dir dmidecode: Display DMI/SMBIOS information from BIOS
cmd1 && cmd2: Run cmd2 if cmd1 is successful find /home -size +500M: Find files larger than 500MB in /home hdparm -i /dev/sda: Display information about disk sda
cmd1 || cmd2: Run cmd2 if cmd1 is not successful whereis command: Locate the binary, source, and manual page of command hdparm -tT /dev/sda: Perform a read speed test on disk sda
cmd&: Run cmd in a subshell locate file: Find the location of file quickly badblocks -s /dev/sda: Test for unreadable blocks on disk sda