ln -s /foo/bar/baz
will create a soft link in the CWD named baz, pointing to /foo/bar/baz.So you see, if you know that you can always skip the destination, then, logically, the source must be the first one!
You mean the target, but that isn’t a logically necessary consequence at all. Conceivably, `ln` could support the following two syntaxes:
ln [options] target
ln [options] link_name target
The way I remember the correct parameter order is that I remember it’s the non-intuitive one.Kind of like when my wife tells me I'm doing something wrong and she wants it to be the other way.. I know she thinks this thing is important, but can't work out which way she wants it done.
but yea, it took me many years to wire down ln's target link_name semantics for some reason.
what helped for me was to reason about the single argument form. ln -s ~/opt/junk/bin/thinger creates a link to thinger in the current directory. this single argument form is easy to remember, if you want to create a link of course you have to specify the name of the target (from which the link name will be inferred) and since it's the only argument it has to be the first one. now if you want to give it a different name, put the name in obvious still open place, the second argument.
Edit: this line of reasoning works for common usage of a lot of other utils too, like zip/tar etc. Even grep - is it grep FILE PATTERN [PATTERN ...] or grep PATTERN FILE [FILE ...] ?