Is there anything that could help me memorise the argument order of the ln command?
Is there anything that could help me memorise the argument order of the ln command?
I'll take anything from little helper phrases over shell extensions to replacements written in Rust. I only use the command occasionally, but I need a fool-proof solution. Do you have any tricks to get it right?
A link operation is meaningless without a target, so that must come first.
If you don't specify a name for the link, a reasonable name can be inferred from the target. So, the link name goes last, where it can be potentially omitted.
For move and copy it's pretty certain which is the 'from' and which is the 'to' - the order intuitively makes sense.
For symlinks it's more ambiguous based on your personal mental model.
For example, if you think about symlinks from the perspective of the original file before a link is created, then the original file represents the 'from' and the link is the 'to' (CORRECT)
But if you are thinking from the perspective of using a link after it's created, then you can easily imagine the symlink as the 'from' - because that's where you start when you follow it, and the target file/dir as the 'to' - because that's where you arrive after following it. (INCORRECT)
All this stuff about source and destination and target or whatever hasn't helped me because those terms are too confusing when it comes to what they do with links. I like to think of it as hitching a new car onto a train. ln is the locomotive, the car that's already there comes next, and then you link the new one to it.
@fell@ma.fellr.net After using unix (mostly not linux!) for 10 years I found that I just knew it and always got it right. I haven't had to think about ln in the last 20 years - my fingers just work. I guess that is one advantage to getting older/wiser. (I'm just hoping I don't get cognitive decline like so many do, though probably I wouldn't for 20-30 more years)