Skip to content

Instantly share code, notes, and snippets.

View gnubyexample's full-sized avatar

Gary Wright gnubyexample

View GitHub Profile
@gnubyexample
gnubyexample / ssh-key-sigcheck.sh
Created March 7, 2012 21:37
key signature check - particularly useful for github in 2012
#!/bin/dash
for pub in $(find ~/.ssh/ -name '*.pub'); do ssh-keygen -lf $pub; done
@gnubyexample
gnubyexample / console-setup.sh
Created March 6, 2012 14:06
console keyboard as you like on Debian and derivatives
#!/bin/dash
apt-get install console-setup
# If you want /etc/default/keyboard populated first then you might precede above with
# apt-get install keyboard-configuration console-setup-mini
XKBMODEL="pc105"
XKBLAYOUT="gb"
@gnubyexample
gnubyexample / manpages-international-remove.sh
Created February 7, 2012 20:51
manpages international remove
#!/bin/dash
for i in 'cs' 'de-dev' 'es' 'es-extra' 'it' 'pl' 'pl-dev' 'pt' 'pt-dev' 'ru'; do echo 'manpages-'$i; done | xargs -r dpkg --purge
@gnubyexample
gnubyexample / seasonal-state.sh
Created February 6, 2012 12:40
seasonal state
#!/bin/dash
ls -d /* | egrep -v '^(/backup|/bak|/lost\+found|/mnt|/proc|/selinux|/service|/sys|/tmp|/media|/srv|/run)' | /usr/bin/winter > ~/localhost.winter
ls -d /* | egrep -v '^(/backup|/bak|/lost\+found|/mnt|/proc|/selinux|/sys)' | xargs -r -i find {} -maxdepth 1 -type d
@gnubyexample
gnubyexample / named-checkzone.sh
Created January 9, 2012 23:57
Check dns record conforms to bind standards
#!/bin/dash
DOM_=wrightsolutions.co.uk;named-checkzone ${DOM_} /var/lib/bind/db.${DOM_}
@gnubyexample
gnubyexample / apache2heavy.sh
Created January 8, 2012 16:42
Apache2 - ip addresses that are heavy users
#!/bin/dash
tail -20000 access_log | cut -d' ' -f1 | sort | uniq -c | sort -g | tail
@gnubyexample
gnubyexample / rsync.dash
Created January 3, 2012 23:59
rsync options source destination
#!/bin/dash
rsync -v -t -ogp -r files /var/www/vhosts/def.com/www/sites/def
Less well: rsync -v -t -r files /var/www/vhosts/def.com/www/sites/def
find /var/www/vhosts/def.com/www/sites/def/files/ -type f -perm 644 -exec chmod 775 {} \;
# You probably meant to include the -ogp flags in your rsync
# 775 file permissions are not great, but it is is one step up from 777 nonsense.
rsync -v -t -og -r rose0non ~/hglocal/
@gnubyexample
gnubyexample / dpkg-query
Created December 3, 2011 17:39
dpkg query - where you are interested in size or want to sort by size - read dpkg-query manpage for explanation of switches
#!/bin/dash
# (c) 2011 Gary Wright - now released into public domain.
dpkg-query -W --showformat='${Installed-Size;-10}\t${Section;-15}\t${Package;-30}\n' | sort -g
dpkg-query -W --showformat='${Installed-Size;-10}\t${Section}\t${Package}\n' | sort -g
dpkg-query --showformat='${Installed-Size;-10} ${Package}\n' -W | sort -g
dpkg-query --showformat='${Package}\n${Description}' -W macaulay*
#dpkg-query --showformat='${Installed-Size;-10} ${Package}\n' -W lib* | sort -g
@gnubyexample
gnubyexample / alias-infolist.sh
Created May 2, 2011 20:14
alias - infolist & baksysconfig
#!/bin/dash
# (c) Gary Wright 2011 now released into public domain.
alias infolist="(cd /var/lib/dpkg/info/;find . -type f -name '*.list' -printf '%f\n' | awk -F'\\\.list' '{print \$1}' | awk -F':' '{print \$1}')"
# --field-separator argument in awk section (-F) includes 3 backslashes (\\\) before the period (.) which is deliberate.
#
# Note: The alias shown here are for easy copy and pasting. Do not expect this shell script to set alias for you. Think.
alias baksysconfig="cd /bak/this/sysconfig/; \
/bin/echo '*shadow* *secret* etc/ssh/ssh*_key etc/.*secret* etc/*/*secret* ' | \
/usr/bin/tr ' ' '\n' | \
@gnubyexample
gnubyexample / ati-radeon-xorg-counter.awk
Created April 24, 2011 22:21
Awk script to pull out relevant ATI & RADEON entries from a /var/log/Xorg.0.log or similar
# (c) 2011 Gary Wright
# Usage of the works is permitted provided that this instrument is retained with
# the works, so that any entity that uses the works is notified of this instrument.
# You may additionally create derivatives under this license,
# or BSD "new" / Apache 2.0 / Any Free Software Foundation (fsf.org) approved license.
###
# Awk script to pull out relevant ATI & RADEON entries from a /var/log/Xorg.0.log or similar
###
/ATI/ { count["ATI"]++ }
/) ATI/ { count[") ATI"]++ }