ln tip (making symlinks)

ln is such an important utility, endlessly useful, and really not hard to use or understand at all, except for when you haven’t used it in a while and check the manpage for its syntax then that’s when shit hits the fan.

It is confusing at best. In my case, the fact that wasn’t straightforward from the beginning, even after “getting it”, the experience of the confusion is what I remember instead of the syntax, and there’s always a lingering uncertainty that kicks in.

This is from the manpage:

       ln [OPTION]… TARGET

TARGET is immediately easy to understand, so is LINK_NAME, and if it was left there it would’ve made a world of difference but then DIRECTORY is introduced, introducing ambiguity with it. Granted, if you keep reading a little further you may catch the explanation, but realistically, how many stop to read the description and don’t go straight to skim the options? And when the five second research fails: it’s a web search.

This may seem obvious to many, it’s fine, it’s not for you. It’s for those scatterbrains, the ADHDs and OCPDs like me that interpret an non-definitive answer as open, where the non-denied what ifs that create more questions. It can be frustrating.

I’m not going to teach you how to use ln but rather a simple mnemonic that might come in handy: treat it like cp.

ln is like copying files, only without copying their data. cp‘s syntax, is among the most memorable in the CLI because it’s one of the first commands you learn along with mv which also has the same syntax ordering: SOURCE → DESTINATION. Works for every case.


ln -s existing-thing-or-source new-thing-or-destination

Hard linking directories is complicated. In syntax: instead of having to define if a directory plays source, destination or object, just maybe think that without the s there’s no plural, so you [hard] link individual files with(out) it:

ln existing-thing-or-source new-thing-or-destination

And the last variation you may, but not really since you can always rm before ln, is -f, which means the same as it means in plenty of other commands:

ln -sf existing-thing-or-source forced(overwritten)-new-thing-or-destination

That’s it. More on it risks making it confusing again. If you do need more advanced things, perhaps you should really carefully read that manpage.

Don’t forget there’s videoconf pet meditation this afternoon at 17hrs.

Remember: ln = cp without the bulk.