Damn Small Linux for a Damn Small Laptop

Tied up with the various issues we’ve had recently with houses, I’ve got a new project. Its to turn my (mother’s) very old laptop into a dumb terminal we can have in the basement in the new house. The kitchen is in the basement and I’m keen not to bring any more hardware into that environment that we need to, just because kitchens are full of liquids and grease.

I’ve got a Toshiba Satellite 210CS, complete with its original “Optimized for Windows 95” sticker. It celebrated its twelfth birthday this year so its not doing too badly! Its had a couple of upgrades from its original configuration – it has a 1GB hard drive, a PCMCIA wirless card that will talk to our 802.11b router, and a memory expansion to take it to 24MB of RAM. The processor is a Pentium 120Hz and judging by the fact that it thinks its June 2nd 2005, its CMOS battery is flat.

On Sunday night (its a bank holiday here so we’ve had Monday off as well) we installed Damn Small Linux (DSL) onto it and hoped for the best. The most impressive thing about this is always trying to boot anything new. This machine predates real PCMCIA standards and predates USB; it has a CD drive but can’t boot from it and often won’t read written CDs. It does have wired network on PCMCIA but can’t boot from that either. And it has a floppy drive … somewhere. So we managed to find the floppy drive, and another machine with a floppy drive in it (we were quite surprised to realise the server has one), and even unearthed a floppy disk in the house. Which is more impressive than it sounds as all our stuff is in storage!

DSL went on like a dream but wrongly guessed the size of the screen on the laptop so on the first attempt when I thought it had stopped and I pressed return a few times to shift everything up the screen a bit, I discovered I had answered “no” to the question “would you like a boot loader?”! So we did that again and now its working fine.

Even more impressively, the DSL installation is happily driving the PCMCIA wireless card, out-of-the-box. Last time we re-installed this machine (we think 3 or 4 years ago) we gave up with getting a binary distro working and Kevin compiled some special Gentoo for it. I was impressed how painless this was, so a big thanks to the DSL people, I must send them some fanmail. Or money, maybe.

The plan is just to use the command line to ssh up to the main in-the-house server and use that for checking mail. We can use lynx and command-line chat equivalents if we get desperate too :)

1 If you were hoping for an update, we’ve commissioned the searches but must complete by the end of May to avoid losing the mortgage. Watch this space.

Fun with Unix: Writing Messages

This is the first in a mini-series of articles about using Linux/Unix to do things other than view logs and edit files. I’m 26 and find that many of my peers weren’t exposed to Unix servers at university, so they miss out on this. If you have any suggestions of things to include in the mini series, let me know please!

Write messages

So to pop up a message on another user’s PC, you’d usually use MSN, right? Well if you’re both logged into the same server there is another way. Just echo your message and then send the program write to get it to the person. Like this:

echo “Hello Kevin” | write kevin

Kevin will get a message on his screen which says:


Message from lorna@server on pts/1 at 22:14 ...
Hello Kevin
EOF

Silence please

To turn off receiving messages, you need to change your mesg setting, by setting it to n:

mesg n

Not surprisingly, you can turn it back on with:

mesg y

That’s today’s installment, have fun!

Mouselessness

Not to be confused with houselessness which I have also been doing a lot of recently, today mouselessness is the name of the game. Inspired by this recent post on Coding Horror here are my thoughts on using a computer without a mouse.

RSI Risk

I posted a while back about last years brush with RSI and it really did seem to settle down for a while. I changed jobs and that also seemed to help for the first few weeks, then start to get worse again. I do concur that the mouse is the root of all hand-related evils at the desk, and use one as little as possible.

Working without the mouse

There are a lot of things you can do without a mouse. I use Opera as my main browser, it has keyboard navigation and I can surf for hours without touching the mouse at all.

There are lots of keyboard shortcuts for Windows (see Jon Galloway’s excellent mouseless computing article for ideas), which I started to get better with. These days however I’m using Linux at work and use a variety of quick shortcuts to help:

  • I use all four desktops, with Ctrl+1, Ctrl+2, Ctrl+3 and Ctrl+4 to get me to where I want to do. Its really good and fast – especially when I remember to press control with my right hand and the number with my left!
  • Opera, as mentioned above
  • Katapult, which is a KDE application which allows you to type Alt+Space and type the program you want to run, it even autocompletes
  • Vim. I do all my development over ssh and running vim. No dragging and dropping of files, no dragging to highlight to copy and paste, no icons to click on to format or open another file. Absolutely everything can be done without moving hands from keyboard and I have to say that spending the time with the cheat sheet and getting better with it was the best thing I’ve done since I taught myself to touch type in my teens. Not only does it save my hands, I’m also faster than my colleagues for most things. If you haven’t tried it for a few years and think is a basic text editor you might be stuck with on a server somewhere, then look again. GVim is available for most platforms with tabbed editing and its got code folding and autocompletion too.

Alternative input

At work I have a microsoft keyboard that I quite like but which has keys which go quite deep when you press them which isn’t ideal. I need to try changing hands with my mouse, but I also have a beautiful Kensington Pro trackball which is excellent. Its a bit strange with the main button in the bottom left below the ball but the ball is good and big and it is good. At home I rarely use a mouse and have a little external keyboard which has shallow button movement when it is pressed – which seems OK.

Mouseless computing

Its perfectly possible to do a lot of everyday actions without the use of a mouse. Getting up to speed with the shortcuts for the applications you use will take time – but I shall be taking the advice from the Coding Horror article and learning a new keyboard shortcut every day from now on. I am switching back to my trackball and will take time and effort to get my desk set up better – and I’ll let you know how I go. In the meantime, tell me whether you have had similar problems and what your favourite keyboard shortcut is. I think mine is Ctrl + G in Opera – to turn off stylesheets.

public/private key SSH on ubuntu

Here are a few notes I made when changing SSH acces for an ubuntu server over to using public/private key authentication. These instructions are for commands run on the server to generate keys which are then used to access that same server from elsewhere.

On the whole the process was exactly as straightforward as you’d think, which was nice. The users followed these steps:

1. Generate keys

The user access the server using SSH (still set up with passwords at this point) and runs the following command to generate keys:


ssh-keygen

We accepted the defaults for both the filename (id_rsa) and left the passphrase empty. Empty passphrases aren’t recommended but there will be automated processes using these keys.

2. Set up to accept

For an SSH server to authorise a user, it must havethe contents of that user’s public key in a file called authorized_keys. The user then comes along with their private key and can then gain access. We put the contents of the public key into the authorized_keys file (which doesn’t currently exist for these users).


cat id_rsa.pub > authorized_keys

3. Log in with public key

The users copied their private keys to their local machines and set up their various ssh clients to use these to gain access. For ssh-ing in from another server (and setting up with some of the clients), its the ssh command as usual but with the -i switch to denote the use of a specified identity file, e.g.:


ssh -i id_rsa user@host

4. Force this to be the only means of access

I had some trouble figuring out which line I needed to change in the openssh config file (at /etc/ssh/sshd_config for me running ubuntu edgy) but in the event, this did the trick:


PasswordAuthentication no

That’s it for today, hope this helps someone … including me next time I want to do something similar :)

Process Email Queue by Waving Mouse

Today I had a problem with a development server. A little, low-traffic thing that I was testing some PHP-sends-email pages on. The emails wouldn’t send although I could see them sat in the queue.

The story gets better but there’s a techie bit between here and the punchline – sorry

Exim commands

mailq – show the emails currently in the queue

sendmail -v -q – send the emails in the queue and give plenty of output with it.

The symptoms

Sending email just caused the screen to hang, I’d get something like this:


LOG: queue_run MAIN
  Start queue run: pid=12282
delivering 1HeAZY-0002YQ-J0 (queue run pid 12282)
R: dnslookup for ****************
T: remote_smtp for **********************
Connecting to **************** [000.000.000.000]:25 … connected
  SMTP<< 220 ********************** ESMTP
  SMTP>> EHLO ****
  SMTP<< 250-***********************

        250-AUTH=LOGIN CRAM-MD5
        250-AUTH LOGIN CRAM-MD5
        250-STARTTLS
        250-PIPELINING
        250 8BITMIME
  SMTP>> STARTTLS
  SMTP<< 220 ready for tls

Randomness!!

The problem was that we didn’t have enough entropy1 to generate the security for the connection … and getting one of my colleagues to rummage in the rack for the server and wave its mouse continuously solved the problem. It was quite a scene :)

1 For diagnosing randomness, I used: cat /proc/sys/kernel/random/entropy_avail

Tabs in Vim

Tabs seem to be out of fashion in the programming world, there are perfectly valid arguments on both sides or the tabs vs. spaces flame war, illustrated with examples from every programming language and text editor combination ever made. You can read any or all of these if you are interested, but that isn’t the issue here.

I use tabs – all the time. My tab stopping is set to 4 spaces but my intention is to use actual tab characters. Its actually surprisingly hard to do this with vim. I’ve added the following lines to my .vimrc which allow me to see whether I have tabs or spaces at the start of the line.


set list listchars=tab:\|_,trail:.
highlight SpecialKey ctermfg=DarkGray

I fiddled with some other settings too, to try to stop everything ending up as spaces (I’m driving my colleagues mad) but to no avail. With these lines:


set shiftwidth=4
set softtabstop=4
set tabstop=4
set noexpandtab
set autoindent
set smartindent

I think those are all the relevant lines … it kind of works but I still need to type the set noexpandtab when I’m editing a file to stop auto-indented new lines from getting space instead.

Its all very exasperating so if anyone has suggestions other than “use spaces” I’d be interested to hear them!

SQLPlus for MySQL

Until recently I spent a lot of time working with Oracle from the command line (via ksh on AIX, in case you’re interested). A change of job means a change of platform and I find myself working with MySQL on a daily basis. I like MySQL – like most PHP programmers this is where I started learning about databases and I’ll always have a soft spot for it.

In Oracle most developers use SQLPlus to work with the database – its the standard command-line tool and the only thing you can guarantee being available in a new environment. It has a wonderful feature where you can type a query and then type ‘ed’ and pull up an editor window with the query still in it … so useful for debugging big statements.

I’ve been struggling to get to grips with MySQL – it has more tools and phpMyAdmin is readily available. However I don’t really use a mouse if I can help it so its not as fast or convenient as the SQLPlus + ‘ed’ combination. So here’s my discovery for this week:

Type \e

Most mysql command-line tools will launch your previous query, with line breaks, if you type \e at the prompt. Fantastically useful and I’m happy and settled once more :)

Kbuntu Add Programs

I’m just getting started with running a linux machine as my main computer at work (yay!), setting everything up today. My tip for installing linux the first time is to get the repositories of software added so you can install more things though “adept” (the program that runs when you choose the “Add/Remove Programs” option from the start menu). To add the repositories just edit this file:

  /etc/apt/sources.list

Then uncomment the lines as directed in the file. You will also need to get the list of available packages by running

  sudo aptitude update

Next time you go to “Add/Remove Programs” you’ll have a much bigger list to chose from, especially if you allow unsupported and proprietary software by ticking the boxes at the top right hand side.

Form Name ID and Label Tags

Just a quick one, but something that confuses me often.

<input name="input_name" id="input_identifier ....

name is what the POST request will see the field called
id is what the label tag will use to figure out which field it belongs to.

Can blogging get you killed?

I’ve just spent the last two hours reading through (this is a disturbing link, you have been warned) Kathy Sierra’s post about the death threats she has been receiving.

Death threats.

One of the most talented and inspirational writers of our time is currently locked inside their house in fear. How can that be right?

Its created waves in the blogosphere, I picked up the news from a blogher mailing list, and they have an excellent article on the subject on their site. The blogher mailing list people have also added their words of support to Kathy onto their own blogs, here and here. And it must be true because its even on the BBC News Website.

I hope this blows over for Kathy, as much as it can, and that justice runs its course. There’s overwhelming support for her but we can’t protect her in the real world and it only takes one nutcase to carry out these threats. She may stop blogging and I can understand that although I’d be gutted. I’ve posted to her site to say this, and also want to state here my support for Kathy whose articles inspire and educate me.

So here I am, a woman blogging on mainly tech subjects, with nothing to protect me but the fact that I have a very tiny readership. It makes you think …