# Find which linux distribution
cat /etc/*release
# diff- generate patch file
diff -Naur original fork > patch.txt
# diff exclude certain files
# http://stackoverflow.com/a/3775636
# -x or --exclude
diff -x '*.foo' -x '*.bar' -x '*.baz' /destination/dir/1 /destination/dir/2
# rsync files over ssh
# source: http://stackoverflow.com/a/9090859
# run from local machine :
rsync -chavzP --stats user@remote.host:/path/to/copy /path/to/local/storage
# run from remote machine if local machine has ssh daemon:
rsync -chavzP --stats /path/to/copy user@host.remoted.from:/path/to/local/storage
# Use wget to scan a webpage for broken links
# https://www.digitalocean.com/community/tutorials/how-to-find-broken-links-on-your-website-using-wget-on-debian-7
wget --spider --recursive --no-directories --no-verbose --span-hosts --level=1 --wait=2 --output-file=wget.log <URL>
# http://www.commandlinefu.com/commands/view/8234/check-broken-links-using-wget-as-a-spider
wget --spider --execute robots=off --wait 1 --recursive --page-requisites --output-file=wget.log <URL>
# wget all files linked from a page
http://stackoverflow.com/a/13574050
wget --recursive --no-parent --level=1 --accept=<list of file extenstions> http://example.com/download/
# redirect all output to file
# http://stackoverflow.com/a/6674348
foo > allout.txt 2>&1
# run all python unit tests in a dir
# http://stackoverflow.com/a/15630454
python -m unittest discover <test_directory>
# run puppet and apply configs
puppet agent -t
# to double check SSL related server errors
# http://askubuntu.com/a/116059
openssl s_client -connect localhost:8000
# specifying cert files etc
openssl s_client -connect localhost:8000 -cert client.cert.pem -key client.key.pem -state -CAfile rootCA.pem
# validate and pretty print json file to console
python -m json.tool foo.json
# Get file perms in octal form
# http://askubuntu.com/a/152003
stat -c "%a %n" *
# delete files from accidentally extracted tar
# http://www.commandlinefu.com/commands/view/2573/remove-all-files-previously-extracted-from-a-tar.gz-file.
tar -tf <file.tar.gz> | xargs rm -r
# cd into realpath instead of symlinked dir
# https://stackoverflow.com/a/2299208
cd -P <dir>
pwd -P