UNIX Advanced Command Reference / Cheat Sheet

Advanced command reference for Linux. We assume you already know basic commands such as ls, pwd, mkdir, gzip, etc. Here are some useful additions which you may not already know.

DNS (Domain Name Service)
host string Perform forward or reverse lookup on string
dig @nameserver string Lookup string's host info from nameserver
File Manipulation
find . -type f -exec grep -l string {} \; -exec mv {} /path \; Move all files containing string to /path
System Hardware Information
grep -i memtotal /proc/meminfo Find total amount of RAM in the system
dmidecode -q Display DMI/SMBIOS information
cat /proc/cpuinfo Display CPU information
egrep '(vmx|svm)' /proc/cpuinfo See if a processor supports hardware virtualization
lspci -tv Display PCI information
lsusb -tv Display USB information
hdparm -i /dev/sda Display disk information for sda
Quick HTML Editing Site Wide
find . -type f -print -exec sed -i -e 's|X|Y|g' {} \; Replace all X's with Y's in all files this directory and below.
perl -pi -w -e 's/X/Y/g;' *.txt Replace all X's with Y's in all files ending with *.txt
find -name '*' | xargs grep 'string' Print filename and all lines containing 'string'
SSH (Secure Shell)
scp -p -r [USER]@[HOST]:file /dir Recursively copy while preserving permissions
ssh-copy-id [USER]@[HOST] Install public key for trusted login on HOST
Troubleshooting
ps -auxf Full process list with Child Process Tree
netstat -tup List all active network connections and state
lsof -i :80 Show information related to http (port 80) connections
lsof -u userid List open files by a particular userid
iftop List active network connections consuming bandwidth
apachetop -f logfile Top for Apache webserver
iptraf Monitor IP Traffic
htop Like top, but with an h
mtr My Traceroute - An improved traceroute
multitail Tail mutiple files at the same time
siege A http/web stress test utility
Samba / Windows File Sharing
smbtree Scan local network for windows shares
Isolate DoS (Denial of Service) Attacks with netstat
netstat -an | grep :80 | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -nr
netstat -anp | grep 'tcp\|udp' | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -nr
netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -nr
netstat -ntu | grep -v TIME_WAIT | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -nr
netstat -n --tcp --udp --numeric-hosts | grep -v 127.0.0.1 | awk '{if (/(tcp|udp)/) { print $5 }}' | sed 's/:.*//' | sort | uniq -c | sort -n | awk '{if ($1 > 20) {print "Count: "$1"\t"$2; }}'
Bit Torrent Clients
rtorrent Bit Torrent Client
aria2 Bit Torrent Client

Contact Information

Lakeside, MT:+1-406-844-2550
Kalispell, MT:+1-406-257-7900
Fax:+1-406-844-3063
Email:info@nivindel.com
Skype (Voice):VoIP Call
Skype (Text):Text Chat
Questions? Click Here for Live Support Chat.

Did you know?

There are over 1.7 Billion people worldwide, representing 27% of the world population, who have access the to internet?

Nivindel can help your business get a larger piece of the pie with our search engine optimization techniques.