Wednesday, 13 June 2012

Listing all available package versions with yum

Sometime I needs to install an older flavour of a package.  You can list these with yum and install a specific version, e.g.

yum --showduplicates list mod_ssl
yum install mod_ssl-2.2.3-53.el5

Thursday, 31 May 2012

Tracing Redirects with curl

I quite often need to debug rewrites and redirects and with curl this is quite easy.

curl -I -L "http://somewhere.com"

also you can add the -k option to ignore invalid certificate errors

Wednesday, 25 January 2012

SSH Piping between remote servers

SSH is without doubt my favourite command line tool. Today I needed to transfer a file between two hosts that I could SSH to, but could not SSH to each other. This is really simple with a bit of standard UNIX piping.

ssh hostA cat somescript.sh | ssh hostB "cat > somescript.sh"

Job done.

Thursday, 19 January 2012

iproute2 cheat sheet

Ok so apparently ifconfig is either deprecated or old fashioned and your supposed to use the 'ip' command instead. Turns out it's really nice and I prefer it to ifconfig,route,already.

Here's some examples:

ip addr - equivalent to ifconfig
ip addr show eth0 - same as above just show eth0

ip ro - show routing table
ip route add default via 192.168.0.254 - set the default gateway
ip addr add 192.168.0.5/24 brd + dev eth0 label eth0:0 - set an ip alias on eth0 and call it eth0:0

ip neigh - show the arp table



Monday, 9 January 2012

Disable a yum repository while running yum update

I wanted to run all updates from the RHEL repositories, but not the rpmforge and WAN Disco ones. Easy.

sudo yum check-update --disablerepo=rpmforge --disablerepo=WANdisco-dev

Saturday, 17 December 2011

Resize images on the command line

I've recently been buying allot of digital downloads and it seems a waste that the album art encoded into the track is often 1500x1500 and taking up valuable disk space.

A quick blast with Graphics Magick solves all

gm mogrify -scale 25% Artwork.jpg

Saturday, 10 December 2011

Rsync happiness

I recently got around to setting up a backup of my data. I decided rather than using something like Drop Box (which i'm sure is great) I'd keep things simple and set up a new EBS volume on my EC2 box and rsync my data there.

Here was the initial command I used to get the first sync in place manually.

rsync -arvzh --progress -e 'ssh -i path to pub key' /dir/to/backup user@host:/backup/dir/here

A quick review of the flags

-a archive mode (preserve timestamps)
-r recurse into directories
-v verbose
-z compress data during transfer
-h output in human readable format
--progress show a nice progress meter (won't want this in script)

-e specify remote shell and put any further args in quotes