ln: Your magical shortcut tool

ln is another magic toy from coreutils, which is where all the good stuff is in Linux. ln creates links, which you can use to make cool stuff happen.

I don’t use a hefty lot of links in my personal directory, but I can tell you about a few times when I’ve used ln for fun and profit.

For example, I don’t use an automounting daemon or a desktop environment that will automatically mount drives or volumes.

Instead, I include them in /etc/fstab, and mount them to /media, like a true Internet superhero.

To save myself time typing out the path to the mountpoint, I use

ln -s /media/sdb1

from my home directory, which creates the symbolic link locally, for convenience. Best of all, I can issue the mount command directly, and it works fine.

mount sdb1

I also use ln to point to the most recent version of some financial files. I have some spreadsheets that increment on a monthly basis, but retain the date as part of the filename.

This makes them a little cumbersome to load, even with tab completion.

2013-07-01-finances.sc
2013-08-01-finances.sc
2013-09-01-finances.sc

Rather than type out the date each time or fumble through tab completion to get the right month and day, I make a new link with ln whenever the newest file is created.

ln -s /home/kmandla/data/2013-10-01-finances.sc /home/kmandla/data/finances

Now I can open that link from within an application and the correct file bounces into view.

ln is good fun and there are a lot of other nifty tricks you can do with it. It’s worth experimenting with this, and in some cases it might be preferable to use a link over a fast directory switcher (like j2 or fasd), if your needs just aren’t that great.

Enjoy. 😉

Advertisements