The zen of UNIX
Wednesday, 29 September 2010
My main trouble with UNIX is that I'll go looking for a quick answer, find it, and then somehow still keep digging until I'm utterly stumped, long after I solved the initial problem. Here's one example:
On the recommendation of my friend Bálint Érdi, I signed on with Dropbox, and I figured one good use of it would be to keep my vimrc files in sync across three virtual Linux computers I'm having to use.
So, I went looking for the originals -- the Vim configuration files on the Linux Mint 8 VM that I am using now. Except I didn't go straight to the VM. I took a detour through Chrome, and typed this in the address box: "where is .vimrc". That got me here, which is a comment thread that happened six years ago.
Of course, the answer is trivial:
# locate vimrc. That's UNIX love right there. If you want to find a file, just
locate it. If you're the almighty root (#), the computer will fetch it without a fuss. But the more fascinating bit is a little further below, posted by the user Wolfbone:
.foorc = runtime configuration file for programme "foo" located in user's home directory.
/etc/foorc (if it exists) = global (all users) runtime configuration file for programme "foo", overridden by .foorc, if it exists.
Suggesting to someone who cannot find an 'rc' file that '#locate vimrc' is a useful command is not very helpful.
I had no idea that vimrc was called that in order to respect this [r]untime [c]onfiguration naming convention. I also had no idea that the ~/.foorc files are there to override /etc/foorc files. Sounds like an architecture thing. I am guessing that the common use is that your IT guy will put configuration files in /etc/foorc, and if you like those, fine. If you don't, just make up your own .foorc files and stick them in the home folder. Neat, but it gets even better.
If you run this
# locate vimrc command, it'll turn up /etc/vimrc.local. If you then
cat vimrc you can see that it defers to vimrc.local if it exists. So, there are two available layers of configuration overrides: first is /etc/vimrc.local, then ~/.vimrc, which reigns supreme. What's the use of that? And how is this implemented in FreeBSD? My initial guess was that the FreeBSD convention is that rc is a file extension, as in mail.rc. But then in the /etc folder I also saw things like rc.firewall. And in /usr/local/etc I saw things called ddclient.conf. What's different between files that start with rc., or end with .rc, or end with .conf?
So many questions, so little time. Still, this is better than my experience with Windows, where things either just work (thank you, Windows 7) or they're so arcane that, if I ever attempt them, it's always on guts alone. I have no theory whatsoever of what might go wrong.