4 ms·
I suspect ln is at the top of the man list because no one can ever remember what order the arguments go in.
by icambron 14y ago
I suspect ln is at the top of the man list because no one can ever remember what order the arguments go in.
- pyre 14y agoln -s target link Easiest way to remember is that it's setup so that you can create multiple links to the same target. E.g.: ln -s /home/.bashrc {~user1,~user2,~user3}/.bashrc
- exit 14y agoi don't see what's impossible about parsing the arguments with target coming last, so i don't see how this works as a mnemonic
- icambron 14y agoThat is a good way to remember it, and also a feature of ln I didn't know. Thanks
- dsl 14y agoThis is bash specific and may not work in your shell. (fish for example)
- niggler 14y agoThe argument order mirrors the order of mv/cp (and the one-argument form gives a hint). I think people stumble upon the hard link/symlink issue.
- larelli 14y agoI could memorize it from the moment I realized that it works exactly like 'cp', i.e. cp <orig> <copy> Hence I think of it as ln <orig> <link> (edit: formatting)
- kanzure 14y agoNow, why isn't that in the ln man pages?
- readme 14y agoIt is. SYNOPSIS ln [OPTION]... [-T] TARGET LINK_NAME (1st form) He just replaced TARGET with 'orig'
- jrockway 14y agoThe confusion comes from understanding what the target of a link is. Of course, it's not the new file you're creating, it's the source. But if you were copying the file, then the target would be the destination. Hence the confusion, I guess. (I don't think I've ever read the ln man page. I learned it by trying it both ways until I learned which way was correct.)
- readme 14y agoI admit it's confusing, but I don't think it can be put much more succinctly than the man page makes it. The part where the name of the link itself is called "link name" really drives the point home. I definitely refer to ln more than any other man page... Every time I use ln I say "target, link name" in my head.
- biot 14y agoOpenBSD always has great documentation: http://www.openbsd.org/cgi-bin/man.cgi?query=ln http://www.openbsd.org/cgi-bin/man.cgi?query=ln SYNOPSIS ln [-fhns] source [target] ln [-fs] source ... [directory] Not to mention the detailed description as well as informative examples.
- vampirechicken 14y agoln, as well as, cp and mv are all 'command source destination'
- grkvlt 14y agoYes, but the commands are normally interpreted differently in English. For example, 'cp A B' is copy from A to B that is, copying source A to destination B. But 'ln A B' could easily be interpreted as link A to B or make A a link to B where it is really making B a link to A. At least, that's why I sometimes forget the order. I think this is because 'to copy' is a transitive verb and 'to link' is instransitive, in the sense they are used here...?
- vampirechicken 14y agoBut with a quick perusal of the man page, you learn how the software works, and you don't have to make assumption based on interpretations of natural languages.
- gsa 14y agocp has two interesting switches -s for symbolic links and -l for hard links. Plus it'll also link whole directory structures with -r. This might be a GNU only feature, I'm not sure.
- dugmartin 14y agoI always remember that it is the opposite of Windows's mklink and then man it when I can't remember which way it is the opposite.
- recoil 14y agoAnother trick nobody else has mentioned is to remember that the 2nd argument is actually optional, so you can do things like: ln -s /path/to/some/file And it'll create a symlink called "file" in the current directory. That wouldn't be possible if the arguments were the other way around.
- taproot 14y agoThat and was it an upper case S or a lower case s?