A collection of computer systems and programming tips that you may find useful.
Brought to you by Craic Computing LLC, a bioinformatics consulting company.

Thursday, October 15, 2009

Remote Desktop Software

In the past I've used VNC as a remote desktop solution for viewing, say, a Linux desktop on a remote Mac, but I've now switched to NoMachine NX.

VNC is widespread and I think most Linuxes come with it already installed. But when I tried to use it recently with a Fedora VNC server and Mac OS X VNC client (Chicken of the VNC) I was seeing performance that made it unusable.

I think the problem stems from a variant of the VNC protocol or software called TightVNC and I believe the default Linux implementation uses this. Running a Tight VNC client on a Windows machine gave reasonable performance and doing the same on Mac OSX might solve the problem.

Instead I decided to check out NoMachine NX, which I had heard about in the past. This is commercial software but there are free versions of the server and client available for all the main platforms.

Installing the server (on Fedora) involves downloading RPMS for the client, node and server (you need all 3) and installing them:

# sudo rpm -i nxclient-3.4.0-5.x86_64.rpm
# sudo rpm -i nxnode-3.4.0-6.x86_64.rpm
# sudo rpm -i nxserver-3.4.0-8.x86_64.rpm

It installs into /usr/NX by default and you start/stop the server with
# /usr/NX/bin/nxserver --status|--start|--stop|--restart

You don't need to bother with any other NX options right now. At least, not if you are accessing machines in a private network. You may need to tweak your Fedora to allow the remote client to access your desktop (I didn't have to).

On the client end (Mac OS X in my case), download and install then fire up the application. It will give you a 'Connection Wizard' which is self explanatory.

The session will open up an X window on your Mac and I find the performance (on a local network) to be more than adequate. With remote desktops there can be issues with the 'scope' of keystrokes - for example you can't Cmd-C some text in the Mac world and expect to Cmd-V it into a Linux app - that sort of thing.

So if you want an open source solution then play around with VNC, otherwise go with NoMachine NX.

Wednesday, October 14, 2009

Fixing Broken Macs

If and when you need to resuscitate a Mac that won't boot up all the way, there are some commands that will save you a lot of time.

If your problem is not a true hardware issue then chances are there are disk errors and so the first task is to check and repair the disks. You can boot off an install CD/DVD or one with repair tools on it, but if you are comfortable with booting UNIX machines then skip that and...

Boot in Single User Mode

Hold down Command-S when you turn the machine on. You should get a gray screen which will quickly turn into a classic UNIX console with all sorts of cryptic text. At the bottom of which should be some instructions to either check the disks or to reboot in 'full' Single User Mode.

Disk repair with fsck

Your first step should be to run fsck, the UNIX disk checking program, with the options -fy. The 'f' forces fsck to check all available filesystems and 'y' answers Yes whenever it would ask you to approve a fix. If you skip the 'y' then you'll be sat there for hours responding to prompts.

# fsck -fy

That will likely produce lots of scary messages about different files. Don't sweat the details, just let fsck do its thing. Any files that it breaks were already broken by the underlying disk issue. fsck won't compound the damage, only repair most or all of it.

When it finishes, run it again! There can be dependency issues with disk fixes so to play it safe just run it multiple times until it reports no new errors. Typically the first run will get them all.

If you want to poke around on the filesystem then you can mount it with:
# mount -uw /

Reboot the System

If you are feeling lucky then just type 'reboot' at the prompt to see if your system comes back all the way. Fingers crossed...

If it doesn't then just restart the machine with Command-S as before and get back to Single User Mode.

'Full' Single User Mode

At this point you are in Single User Mode but with only the basic services. You can start up a bunch more stuff with

# sh /etc/rc.d

You'll see a bunch more verbage on the console. Keep an eye on it to see if any services are not able to start up - important clues to your problem. You'll either get a system prompt or an error. Hit return to get the prompt if you don't see one.

Now you have access to pretty much all the command line programs, man pages etc. an you are free to do untold damage to your system...


One useful program to know about is diskutil, which is the Mac tool for messing with disks. Look at the man page for details.

To see what disks the system knows about:
# diskutil list

To eject a CD/DVD in the drive (your device name may be different)
# diskutil eject /dev/disk1

Zapping the PRAM

You'll see mention about zapping the PRAM memory in the machine by starting it up while holding down Option + Command + P + R (don't worry about Shift for the P and R). Hold them until your hear two chimes.

This is easy to do - and has never had any effect on any system that I've played with...

Booting from a CD/DVD

To force a boot from a CD with recovery tools on it, turn the machine on, pop the disk in and hold down the C key. You should get to a gray screen with the spinning indicator. Let go of the C key and you should get an OS install menu, or whatever you have on your CD.

If a simple disk repair doesn't fix the issue then you may need to reinstall the OS from disk. Not a problem but be sure to select 'Archive and Install' in order to keep your existing files. Some might say just go for a reinstall regardless of the problem - but I would strongly suggest doing a disk repair first.

Good luck with your fix.

Tuesday, October 13, 2009

Rails Production Environments

Two things that I always forget when working with a Rails app in production mode - without them you get the development environment.

$ rake db:migrate RAILS_ENV=production

$ script/console production

Archive of Tips