Thursday, August 19, 2010

ls colors on Ubuntu

I ls-ed some files today and noticed a few listed with blue backgrounds and white text. I use the --color option to ls because it's pretty, and because the colors provide information that's not always blindingly obvious from regular ls output. Case in point, what did this blue background with white text mean?

It turns out that, at least for Ubuntu 9.10 an 10.04 (the two I tried), you can see a list of the colors that ls uses for various things by typing:

dircolors --print-database

Now, I had a hunch that these files were hardlinks, and sure enough, I saw this line:

HARDLINK 44;37 # regular file with more than one link

And looked up a few lines to see that, yes, 44 is blue and 37 is white. Cool. Just to be extra sure I passed the file names to the stat command and saw the, links: 2 for those files.

Thursday, August 5, 2010

How not to mount a particular server with autofs

There are a couple servers that I use the fancy new (to me at least) autofs scripts to mount on my Ubuntu 9.10 client machine. You know, the ones that let you just cd /net/servername/exportname and it automagically turns that into the command to mount that export from that server at that mountpoint (so cool). To test something out though, I wanted to make sure one of the servers was not auto-mounted by autofs. The simple way to tell autofs to ignore that server (let's call it, foobarbaz) is to edit /etc/ and put this snippet right after the key="$1" line:

# don't mount foobarbaz, for now:
if [ $key = "foobarbaz" ]; then

Then restart autofs:

sudo /etc/init.d/autofs restart

And autofs automagically mounts any nfs server except foobarbaz.

Tuesday, August 3, 2010

Mac nfs client, Linux nfs server

I have a Mac laptop at work and it's been interesting to play with. We have nfs mounted home directories for our Linux workstations and I thought, hey, my Mac is a UNIX machine, it should be able to mount that nfs export too! Turns out, no, not by default. You get a nice "Operation not permitted" error message. The problem is that Mac nfs clients insist on using high numbered TCP ports, and Linux nfs servers by default insist on rejecting clients that use high numbered TCP ports.

You can tell the Linux server to stop rejecting clients using high numbered ports with the insecure option in /etc/exports, or you can tell your Mac client to stop using high ports with the resvport option to your mount command. Most websites I found while googling for this just listed the Linux nfs server solution, which works fine if you have control over the server. Most people have a lot more control over their client.

For autofs on the Mac, put ,resvport at the end of the /net line in /etc/auto_master, and at the end of the AUTOMOUNTD_MNTOPTS line in /etc/autofs.conf and then restart autofs (I was getting tired of all this at this point and just rebooted my Mac, I'm sure there's a less drastic way to restart autofs).