Function: Linux Version
Usage: uname -a && cat /etc/*release

Function: Largest Directory/Files 
Usage: du -hsx * | sort -rh | head -10

Function: Quick Vhost
Usage: bash <(curl justcurl.com  -H "host: example.com " -H "x-docroot: /var/www/vhosts/example.com/public_html ")

Function: Octet Permissions
Usage: stat -c '%A %a %n' .* * 

Function: Add Swap & Persistance
Usage: dd if=/dev/zero of=/swapfile bs=1024 count=2015536 && mkswap /swapfile && swapon /swapfile
Usage: echo "/swapfile swap swap   defaults   0 0" >> /etc/fstab

Function: Make Sure You Are Actually Using Swap
Usage cat /proc/sys/vm/swappiness
sysctl vm.swappiness=30
add to /etc/sysctl.conf vm.swappiness=30

Function: Reset Folder and File Permissions (Great for Wordpress)
Usage: find . -type d -print0 | xargs -0 chmod 02775
       find . -type f -print0 | xargs -0 chmod 0664

Function: Drop Caches
Usage: sync && echo 3 > /proc/sys/vm/drop_caches

Function: Largest Open Files
Usage: sudo lsof -s | awk '$5 == "REG"' | sort -n -r -k 7,7 | head -n 50

Function: Log Rotate
Usage: logrotate -vf /etc/logrotate.conf

Function: Move All Contents Up Partent Directory
Usage: mv * .[^.]* ..

Function: pwgen
Usage: pwgen -B -c -n -y 15

Function: Scan for all TCP and UDP Open Ports
Usage: sudo nmap -n -PN -sT -sU -p-

Function: Find all .conf
Usage: find /etc -name "*.conf" | xargs ls –l

Function: Phrase to file
Usage: httpd -S > /home/rack/domains.txt 2>&1

Function: TAR Compress
Usage: tar cfzv backup-$(date +%Y-%m-%d).tar.gz /home

Function: TAR Uncompress
Usage: tar xvzf

Function: Sed and Replace
Usage: sed -i 's/before/after/g' /home/file.txt

Function: Quickly find Large Files and Directories
Usage: du -h /var --max-depth 1 2>&1 | grep -v "^du: cannot read" | sort -h && ls -alSr /var | grep -v ^d | grep -v ^l | tail

Function: Search for a String
Usage: grep -R "DENY" /etc/

Function: Create SSH Key File
Usage: ssh-keygen -t rsa -b 4096 -C "$(whoami)@$(hostname)-$(date -I)"

Function: Check for Change Log (OpenSSH Example)
Usage: rpm -q --changelog openssh | grep CVE

Function: Reverse Rsync
Usage: rsync -avz -e "ssh -p55555" root@192.x.x.x:/mnt/archive.tar.gz /mnt/backup

Function: Issue Command based on iNode 
Usage: find . -inum 1446302 -exec cat {} \;

Function: Bytes each IP consumed in the last week.
Usage: for i in $(cat access_log |awk '{print $1}' | sort -nr |uniq -c |sort -nr |head -20 | awk '{print $2}'); do echo $i used: && grep $i access_log | awk '{s+=$10} END {print s}'; done

Function: Command Line PHP Mail Test
Usage: php -r  "mail('ceo@example.com', 'php test mail', 'test worked');"

Function: Awesome Strace
Usage: pgrep "php-fpm|php5-fpm|apache2|httpd|nginx" | awk '{print"-p "$1}' | xargs strace -tts 4096 -vvvf 2>&1 | tee /root/strace.log

Function: Reset file ownership/permissions on a hosed file system (RPM)
Usage: for p in $(rpm -qa); do rpm --setperms $p; done
              for p in $(rpm -qa); do rpm --setugids $p; done

Function: Find Installed Package Version (Ex. apt PHP)
Usage: dpkg -l | grep php| awk '{print $2}' |tr "\n" " "

Function: IP Blocks for entire Countires
Usage: http://www.ipdeny.com/ipblocks/data/countries/

Function: Truncate / Clear out File
Usage: truncate -s 0 test.txt

Function: Copy File from Specific date onward
Usage: find . -type f -newermt '7/12/2018 01:00:00' -exec cp -a --parents -t backup/ "{}" \;

============= UNSORTED ===============

wget -m -r -nH --cut-dirs=5 ftp://user:pass@server//absolute/path/to/directory

worker_rlimit_nofile 65535;

php /path/to/wp-cli.phar search-replace 'http://example.com' 'https://example.com' --skip-columns=guid --dry-run

ps h --ppid $(cat /var/run/apache2.pid) | awk '{print"-p " $1}' | xargs sudo strace

find $1 -type f -exec stat --format '%Y :%y %n' "{}" \; | sort -nr | cut -d: -f2- | less


dig A plutokorea.com @ns1.hoshisato.com

ps awfuxx | grep mysql|awk '{sum+=$4} END {print sum}'

watch "COLUMNS= ps aux | grep [r]econnect"

cat output.json  | python -m json.tool

tar -cvzf archive.tar.gz archive/* 
split -b 200M archive.tar.gz "archive.tar.gz.part"
cat archive.tar.gz.parta* > archive.tar.gz
(Encrypted Archive)
tar -czvpf - archive/* | gpg --symmetric --cipher-algo aes256 -o archive.tar.gz.gpg
(Decrypt Archvive)
gpg -d myarchive.tar.gz.gpg | tar xzvf -
$ dig hoshisato.com @ +short

sudo dd bs=4M if=/home/antergos-17.6-x86_64.iso of=/dev/sdb status=progress && sync

while :; do sync; sleep .5; done

for file in /proc/*/status ; do awk '/VmSwap|Name/{printf $2 " " $3}END{ print ""}' $file; done