Tips

Renewing DHCP leases from the Terminal in Mac OS X

On OSX, it takes a handful of clicks to release and renew the DHCP lease through the GUI. For someone who usually has a Terminal (or like five) open, a way to do it from the commandline would be nice. Figuring out how to do this took longer than the five seconds I wanted it to, so I thought I'd share.

Mounting partitions from disk images in Linux

I've recently been working extensively with disk image files (actually Compact Flash images, but that's not a useful differentiation). The first time I tried to mount one to work on, with a simple "mount -o loop hd.img /mnt", I was confronted with "mount: you must specify the filesystem type". Okay, then -- "mount -o loop hd.img /mnt -t ext2". Still no love. What gives? A couple of seconds of actually thinking about it gives the answer -- mount mounts partitions -- not disks.

The solution is straightforward enough, but somewhat burdensome. I'll present a shell script to make it easy.

A tip for dd: get a progress report

Many have been the times when I wished the dd utility gave progress messages. It's annoying to be some unknown percentage through some gigantic operation. Somehow, despite the fact that I must have read the help a million times, I never noticed that there was a way to do this. Maybe you didn't either.

Exit codes for bash pipelines

When building a pipeline for a shell script, you may come across an unpleasant situation: some program fails and returns a nonzero exit code, but one of the subsequent programs does not register an error and returns an exit code of zero.

A tip for cygwin users: Use rxvt

Windows becomes a remarkably more useful tool for geeks when it has cygwin installed. I basically always have at least one bash shell open. Historically, I have just used it in a normal Windows console. However, there's a cygwin package which is a Windows build of rxvt that works without X, and I recently started using that instead (rxvt is a fairly slim terminal emulator). Life is a lot better.

A tip for when dhclient mysteriously fails

If you find that dhclient (the common DHCP client for Linux) mysteriously fails -- check that the loopback interface is up. "ifconfig lo up".

Syndicate content