Archive for September, 2005

Backup Del.icio.us

Tuesday, September 27th, 2005

I find I’m moving more and more to a networked way of working. I don’t want to be tied to static files on one machine because I can’t guarantee where I’ll be next but wherever that is I want access to the same information.

This is why I use IMAP for email, bloglines for RSS reading and del.icio.us for bookmarking.

But what if del.icio.us went down?

To backup is simple. wget http://del.icio.us/api/posts/all --http-user=username –http-passwd=password
will download all your del.icio.us posts into one xml file (saved as “all” - you might want to rename it) which you can then store safely.

(NB this sends your password in the clear and it could be seen by anyone else using the same machine if they were running ps at the time. If you are concerned about this man wget will provide you with some suggestions for keeping your details private.)

I Was Wrong…

Sunday, September 25th, 2005

As a Suse user, I was pleased by the ability to use pin to find packages and yast -i to install them from the command line. Pointing my yast sources to the Suse ftp servers meant I didn’t even have to reach for a disk when I wanted to install something. I thought that was pretty good.

But apt-cache search beats pin hands down and apt-get install makes yast -i seem like a dinosaur.

The more I use Debian, the more I love it.

Speed Up Posting to Wordpress

Saturday, September 24th, 2005

When I hit my “Press it” shortcut, I’m often frustrated by how long it takes for the Wordpress Admin section to load. Okay, I’m impatient. It’s only around 4.6 seconds on average but seeing as I often post from home and the installation is on my home server, there should be zero latency. Where’s the delay?

Looking closer at the problem, I realised that the culprit was the section of Dashboard that loads in headlines (and the most recent post?) from the blogs of Wordpress developers.

The file to edit is wordpress/wp-admin/index.php and the section that controls this is the part that begins <div id="planetnews"> (line 129 on a default installation of Wordpress 1.5.2) up to and including the closing </div> (line 141).

One quick edit later deleting the entire section and Dashboard loads in 0.48 seconds. Much better. Now for every 1000 posts I make, I’ll save myself an hour… I’ll be the first to admit, it’s not a productivity hack but it does makes Wordpress feel more responsive and more pleasant to use.

Shutdown From GDM without Typing Root Password

Saturday, September 24th, 2005

On the default Debian 3.1 setup, you need to be root to shut your computer down. This makes sense on a server but is a nuisance on a desktop machine.

To enable ordinary users to shutdown without having to type the root password, you need to use sudo which allows named users to run certain commands as if they were root.

The configuration file /etc/sudoers is edited by root with the tool visudo. Since visudo uses vi as the default editor you may want to change this unless you’re comfortable with its somewhat cryptic interface.

Your default editor is controlled by the $VISUAL variable. To permanently set your default editor as root edit /root/.bashrc and add the line export VISUAL=/usr/bin/joe, replacing joe (my favourite) with your own favourite console editor: /bin/nano is installed by default on Debian and is simple to use.

Now that you’re ready to edit, run visudo. You could edit the file directly but visudo has two added benefits: it prevents more than one person trying to edit the configuration file at the same time and more importantly it provides syntax checking when you finish editing and warns you if you’ve made any mistakes.

In the section headed # User privilege specification add: tim ALL = NOPASSWD:/sbin/shutdown -[hr] now (Obviously replace “tim” with your own username!)

Now you will be able to run shutdown as an unprivileged user without having to enter a password. Remember that /sbin will not be in your $PATH so type /sbin/shutdown -h now to run it.

Once this is working, you are ready to enable shutdown in gdm. Edit /etc/gdm/gdm.conf and change the line SecureSystemMenu=true to read SecureSystemMenu=false. You will no longer need to enter the root password when you select the Shutdown or Restart options in the gdm drop down menus.

Convert HTML to Text with Lynx

Friday, September 23rd, 2005

Quick tip: to convert a html document to text, stripping out all the markup tags and just leaving the content, use the lynx browser:

lynx -dump example.html > example.txt

This works on both local and remote files.

Stop /etc/resolve.conf Changing on Boot

Thursday, September 22nd, 2005

When I booted my system today, I found that mail had stopped working (by which I mean the unix command line utility “mail”).

Using verbose mode revealed that the problem was to do with name resolution.

tim@withnail:~$ echo hello | mail -v -s "Test" nobody@example.com
LOG: MAIN
< = tim@example.com U=tim P=local S=331
delivering 1EIDKX-00021e-VF
R: dnslookup for nobody@example.com
LOG: MAIN
== nobody@example.com R=dnslookup defer (-1): host lookup did not complete

I checked my /etc/resolve.conf into which I’d hand-coded the ip addresses of my ISP’s name servers and found that my entry had been replaced with the local address of my router/dhcp client.

A bit of googling later and I realised that it was the dhclient that was changing the file during the boot process. My router was supplying itself as the DNS and dhclient was doing its job and accepting this as true.

To prevent this happening, edit /etc/dhclient.conf and add the line:

supersede domain-name-servers a.b.c.d, e.f.g.h;

where a.b.c.d and e.f.g.h are the ip addresses of the DNS servers you wish to use in place of the address(es) supplied by your dhcp server. Separate multiple addresses with commas and terminate the whole sequence with a semi-colon.

man dhclient.conf for more information on syntax and options.

This has also fixed my problem with Exim4 taking 10-20 seconds to start - clearly that was a DNS issue - so I’ve disabled yesterday’s hack in case it leads to problems further down the line.

Speeding Up Debian Boot Process

Thursday, September 22nd, 2005

My MTA (exim4) was taking about 10-20 seconds to start, holding back the boot process so I’ve tried this simple hack: Make Debian boot faster

Edit the startup script /etc/init.d/rc.
Changing the line:

startup $i start

to the following:

startup $i start &

Launching the startup scripts in parallel rather than waiting for each to complete first before running the next could cause problems with dependencies but on a vanilla 3.1 install it hasn’t caused any trouble (so far) and the system boots noticeably faster.

Helpful Debian Tutorials

Wednesday, September 21st, 2005

I’ve found this excellent tutorial on setting up printers in Debian too late. However it has helped me with the final piece of the puzzle and I now have printing working in firefox under KDE after following the advice to replace:

lpr ${MOZ_PRINTER_NAME:+'-P'}${MOZ_PRINTER_NAME}

with

kprinter --stdin

in the firefox printer properties.

The site debiantutorials has plenty of Debian tutorials, designed to be easy enough for someone migrating from windows. They’re a great timesaver if you’re looking for how to do something not officially supported by debian such as playing encrypted dvds and other codecs such as wmv or installing the nvidia 3D drivers.

Usability v Curiosity: On Switching to Debian

Tuesday, September 20th, 2005

I’ve finally done it and made the switch to Debian.

I wanted to reinstal Suse 9.2 (9.3 looks good but has issues on my computer and I’m too busy to fix them) only to find that my installation disk was scratched and wouldn’t work. I’ve become increasingly frustrated with aspects of Novell’s distro recently and, being in a hurry and having a Debian 3.1 disk to hand decided to make the jump.

As I noted before, the installer was straightforward although the partitioner interface was not as clear as it could have been. Configuring XFree86 was far easier than I remember. Overall, very easy for someone with a little previous experience of linux.

Setting up the printer however was a confusing struggle. An hour of googling and experimenting and I got it running in the end. Suse’s Yast is definitely a far easier tool for setting up peripherals and one that masks a lot of the underlying complexity (making it better for a user who just wants to print but less interesting for the geek who wants to learn all about how it works).

I was naively surprised to realise that Debian does not support mp3 encoding out of the box but soon fixed this by adding a new source to my /etc/apt/sources.list:

deb ftp://ftp.nerim.net/debian-marillat/ sarge main

This allowed me to

apt-get update
apt-get install lame

and I was able to start creating files for my new mp3 player. I’m an instant apt-get convert. What a great package installer.

Overall, I’m very happy with Debian so far. It lacks the Suse cosmetic polish and exposes more of the underpinnings of the system which may not appeal to everyone but if you value curiosity over usability then Debian may be right up your street.

Sorting Audio Tracks on the Zen Nano

Tuesday, September 20th, 2005

Podcasting is overrated but I am addicted to IT Conversations.

I’ve been looking for a portable MP3 player that works well with linux for a long time. I wanted something small and light, with long battery life and a backlit display that shows the file name. I wanted to be able to mount the file system and copy files across directly as well as the ability to delete files on the device itself. One gigabyte seemed the ideal size: just enough space to squeeze a few albums in as well for when I need a break from the spoken word.

Finally I’ve found the ideal player for my needs: the 1GB Zen Nano Plus.

Creative Zen Nano Plus

It’s very small, fitting into that tiny jeans pocket for which I’ve never previously found a use. It runs around 18 hours on a single charge, takes AAA batteries, supports drag and drop and uses USB 2.0. (It has a number of extra features too like radio, direct encoding to mp3, voice recorder etc that I do not want or need but one never knows when they might come in handy).

It might lack the smooth finish of an Apple device but it is perfect for my needs. It’s small and light enough to take anywhere and not notice you’re carrying it. Now I can make the most of otherwise dead time spent travelling, queuing, shopping or waiting.

Ordering Tracks
Albums are defined by folders. However, tracks within each album/folder play in alphabetical order rather than track number order. To get round this, the supplied Windows software from Creative manipulates the file names:

When you sort your audio files using ID3 tags, Zen Nano Media Explorer adds a 3-digit prefix (a number from 000 to 999) to each filename. For example, Song 1 is renamed as 001_Song 1.

(From the Creative Windows help files)

Since I’m using linux, I’ve written a quick and clumsy bash script that does the same thing: nanoplaylist.

After ripping a CD to mp3s, cd to the generated directory and run the script to rename each file appropriately.

eg

tim@withnail:~/mp3/WAITS Tom/Small Change$ ls
WAITS Tom - Bad Liver And A Broken Heart.mp3
WAITS Tom - I Can't Wait To Get Off Work.mp3
WAITS Tom - Invitation To The Blues.mp3
WAITS Tom - I Wish I Was In New Orleans.mp3
WAITS Tom - Jitterbug Boy.mp3
WAITS Tom - Pasties And A G-String.mp3
WAITS Tom - Small Change.mp3
WAITS Tom - Step Right Up.mp3
WAITS Tom - The One That Got Away.mp3
WAITS Tom - The Piano Has Been Drinking.mp3
WAITS Tom - Tom Traubert's Blues.mp3
tim@withnail:~/mp3/WAITS Tom/Small Change$ nanoplaylist
tim@withnail:~/mp3/WAITS Tom/Small Change$ ls
001_WAITS Tom - Tom Traubert's Blues.mp3
002_WAITS Tom - Step Right Up.mp3
003_WAITS Tom - Jitterbug Boy.mp3
004_WAITS Tom - I Wish I Was In New Orleans.mp3
005_WAITS Tom - The Piano Has Been Drinking.mp3
006_WAITS Tom - Invitation To The Blues.mp3
007_WAITS Tom - Pasties And A G-String.mp3
008_WAITS Tom - Bad Liver And A Broken Heart.mp3
009_WAITS Tom - The One That Got Away.mp3
010_WAITS Tom - Small Change.mp3
011_WAITS Tom - I Can't Wait To Get Off Work.mp3

The script assumes that you have not modified the mp3s since you ripped them and that your software has ripped them sequentially, first track first. Download nanoplaylist here.