/* STORAGE / FILESYSTEM / MOUNTS / PERMISSIONS *********************************************/ # Lists storage devices and mount points lsblk // aliased from 'lsblk -o NAME,SIZE,FSTYPE,LABEL,UUID,MOUNTPOINT' blkid // Useful to get partition UUID's # List files ls // aliased from ' ls++'; uses plugin lsl // aliased from '\ls --color=auto --group-directories-first -Ah' lsr // aliased from 'ls -ltr'; displays files by modification date # Lists mount points and used/available space df // aliased from 'df -h -P --total --exclude-type=devtmpfs 2>/dev/null' df -hPT // -T shows filesystem type # Disk usage and management ncdu # Lists all directories tree // aliased from 'tree -dA' tree -L 2 // as above but limits to 2 layers deep # Change ownership and permissions chmod sudo chmod -R 700 // Require root to access folder chown chown -R : path/to/directory // Change owner of entire directory recursively # Display files and directories in current directory, from smallest to largest du // aliased from 'du -sm ./* | sort -n' # Kills process locking a file fuser -k /* SYSTEM MONITORING / STATISTICS ********************************/ # Sysstat performance monitoring utilities sar // collects all system statistics sar 1 3 // prints stats every 1 second, does it 3 times iostat // CPU and IO stats mpstat // aliased from 'mpstat -P ALL'; CPU stats pidstat // Process ID stats pidstat -d <#> // Reports disk IO in intervals of '#' seconds # Displays system statistics in real time top htop # Displays uptime and users w # Displays tree of active processes pstree # Displays running processes ps ps aux | grep // Displays all running processes containing ps -u // Show all processes by specific user cpuu // Process CPU Usage; from 'ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10' /* BENCHMARKING **************/ # Read 32GB's then toss it dd if=/dev/zero of=/dev/null bs=1M count=32768 /* NETWORKING / SECURITY ***********************/ # Display status of network interfaces ipa // all interfaces; aliased from 'ip address show scope global up' ip4 // ipv4 interfaces aliased from 'ip -4 address show scope global up' ip6 // ipv6 interfaces aliased from 'ip -6 address show scope global up' ipr // routing details aliased from 'ip -4 route show scope global' ip6r // ipv6 routing details aliased from 'ip -6 route show scope global' ifconfig // Also displays interface information ifconfig eth0 192.168.1.1 // Assigns an address to an interface ifconfig eth0:1 10.0.0.53 // Creates virtual interface linked to real interface ifconfig wlan1 up // Enables an interface ('eth0 down' disables eth0 interface) ip route get 8.8.8.8 // Easy way to find active interface quickly # Shows current active connections netconnections // aliased from 'netstat -tuapw --numeric-hosts --numeric-ports' # Gives current WAN IP address wanip // aliased from 'curl ipinfo.io/ip' # Test if local/network firewall blocks telnet; no output if network firewall block in place tcpdump host # Displays network statistics in real time iptraf-ng // Will require sudo/root # Displays firewall rules iptables -L # Network exploration tools nmap nmap // Full scan of hosts on the network nmap -p80 // Scans range 192.168.1.0 - 192.168.1.255 for port 80 'nmap -sT -sU -T5 -p 1-1024' // Stealth TCP/UDP scan for first 1024 ports - highlighted because effective nmap -sL // Passive reverse-DNS on hosts to learn names nmap -sn // Pings all ip's on the 192.168.1.0 network nmap -PS // TCP+SYN sent, SYN/ACK received, RST sent; port probe nmap -PA // Similar above, but ACK instead of SYN; port probe nmap --traceroute // Determine port/protocol most likely to reach target arp // Hosts that have recently attempted to connect /* GUIDE: * = 192.168.1.0/24 etc. * = 192.168.1.0 etc. (no hostmask) * * ifconfig // Look at inet addr: and Mask to figure out network to scan * nmap -sn // To simply check if the hosts are online * nmap // Will do a full port scan as well */ # Traceroute 2.0 mtr # Calculates network assignments ipcalc # Shows program bandwidth use nethogs # Shows bandwidth use on an interface iftop # Lookup domains nslookup nslookup 8.8.8.8 // Does the domain lookup from google's public DNS # List network activity lsof -i // All activity lsof -i :80 // Only web processes using port 80 lsof -P -i -n // Shows all applications using the internet # SSH through intermediary if host is unreachable from local network ssh -t ssh /* ADMINISTRATION / DATABASES ****************************/ # Copy MySQL Database to a new server via SSH; fastest way to migrate DB to a new server mysqldump --databases --force --log-error=/root/mysql_error.log -uUSER -pPASS OLD_DB_NAME | ssh -C user@newhost "mysql -uUSER -pPASS" /* SEARCHING / EDITING / REGULAR EXPRESSIONS *******************************************/ # Outputs a column, where 'x' indicates the column number awk '{ print $x }' # Case insensitive recursive search through files from current directory for and prints line number grep -iTrn * # Escape aliases to run regular command \ /* CRON JOBS AND SCHEDULING ***************************/ # Execute a command at a given time echo "ls -l" | at midnight /* FUN *****/ # Cow tells you something in pretty colors moo // aliased from 'fortune | cowsay | lolcat' # Does a matrix thing cmatrix # Prints system info with image neofetch # Makes a choo choo train sl # Terminal Calculator, can do conversions, too calc // aliased from 'qalc' because q is awkward to type # Accounting tool ledger # hackernews / y-combinator in the terminal haxor-news hn top // Shows top stories, other options available hn view <#> -c // Use this to view comments, replace '#' with the story number # Display weather forecast curl wttr.in # Prints your most commonly used commands history | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head # Hexadecimal dump of /dev/urandom hexdump -C /dev/urandom | grep 13\ 37 // grep highlights characters in the dump # Prints an infinite loop installation screen that does nothing j=0;while true; do let j=$j+1; for i in $(seq 0 20 100); do echo $i;sleep 1; done | dialog --gauge "Install part $j : `sed $(perl -e "print int rand(99999)")"q;d" /usr/share/dict/words`" 6 40;done # Opens firefox in a sandbox, whitelists custom homepage, and disowns it from the terminal firejail --whitelist=~/public/Homepage firefox & disown # Displays installation date of the filesystem (adjust sdb2 to correct drive/partition) installdate // aliased from 'sudo tune2fs -l /dev/sdb2 | grep "Filesystem created:"' # Output your microphone to a remote computers' speaker dd if=/dev/dsp | ssh -c arcfour -C username@host dd of=/dev/dsp // Uses ssh