News for hackers. Stuff that matters.
Re:I always forget the argument order of the `ln -s` command by terra_t on Wednesday December 08, 2010 @03:33PM (#1984504)
I used to have this problem. Then I realized that if I want to really copy a file, I type

$cp file_from file_to

and that

$ln -s link_from link_to

has a very similar effect to the cp command above. I haven't messed this up ever since.

Re:I always forget the argument order of the `ln -s` command by jackowayed on Wednesday December 08, 2010 @05:42PM (#1984991)
This phrasing confused me more.

`$ ln -s link_from link_to` would imply the reverse behavior. How does a symlink point from the actual file to the thing-that-looks-like-a-file-but-is-really-a-symlink? The file doesn't even know whether there are symlinks pointing to it.

Applying your definitions of "link from" and "link to", this:

<a href="http://google.com/>Google</a>;

creates a link from google.com to the hyperlink on your site.

I find the top reddit comment:

    cp existing new
    ln -s existing new
much, much more useful. You want to create a new link pointing to an existing file, which has the same ordering as when you use cp to create a new file with the content of an existing file.
Re:I always forget the argument order of the `ln -s` command by joshwa on Wednesday December 08, 2010 @09:11PM (#1985692)
Less ambiguously:

  cp    existing_thing new_thing
  ln -s existing_thing new_thing
Re:I always forget the argument order of the `ln -s` command by MicahWedemeyer on Thursday December 09, 2010 @08:32AM (#1987309)
That's exactly how I remember it too

  ln -s 'the one that exists' 'the one that doesnt exist'
I actually say that to myself as I'm typing the command. Since I started doing that, I've never gotten it wrong.
Re:I always forget the argument order of the `ln -s` command by phlux on Wednesday December 08, 2010 @06:00PM (#1985078)
I say in my head "link symboliicaly from HERE to THERE"

It took me a long time till I realized that saying it thus made me always recall it properly.

Re:I always forget the argument order of the `ln -s` command by StavrosK on Wednesday December 08, 2010 @03:56PM (#1984574)
I used to have this problem too, and then I read the linked article and now remember the relationship between ln and cp and never got it wrong since.

Also I wonder how many people can say the same thing as the article and still get upvoted.

Re:I always forget the argument order of the `ln -s` command by terra_t on Wednesday December 08, 2010 @04:56PM (#1984791)
I said it in fewer words and didn't add any adsense junk.
Re:I always forget the argument order of the `ln -s` command by brown9-2 on Wednesday December 08, 2010 @05:11PM (#1984843)
The problem with "from" and "to" is - which is the from and which is the to?

Is the "from" the file/dir I want to copy "to" a link?

Or is the "from" the name of a link I want to point "to"?

The dual meaning of some terms that the concept of links and making links creates causes a lot of this confusion, IMHO. Are we using terminology that refers to the act of creating the link or that refers to the direction of the link?

Similarly, I don't think it helps that the usage text and manpage for ln refer to "target"s.

(I know what you mean by your examples but I wanted to share my pet theory as to why this is always so hard to remember)

Re:I always forget the argument order of the `ln -s` command by xentronium on Wednesday December 08, 2010 @05:32PM (#1984942)
"to" is an entity that doesn't exist yet.
Re:I always forget the argument order of the `ln -s` command by kaerast on Wednesday December 08, 2010 @05:55PM (#1985049)
Exactly! The rule is for that commands of two letters in length (cp, ln, mv) the file on the end is the one that gets created. For commands of three letters in length (tar, zip) the file that gets created is the first one. And then there's the exceptions that prove the rule like scp and ssh.

And people say Linux isn't user-friendly! :)

Re:I always forget the argument order of the `ln -s` command by jedbrown on Wednesday December 08, 2010 @04:53PM (#1984777)
It's so similar to cp that GNU cp has

  cp -l from to
Re:I always forget the argument order of the `ln -s` command by steve-howard on Thursday December 09, 2010 @04:42AM (#1986800)
Good, but cp -l is for hard links and cp -s is for symlinks. Most of the time people want the latter.
Re:I always forget the argument order of the `ln -s` command by billswift on Thursday December 09, 2010 @12:44AM (#1986237)
I used to just cheat. I normally cd-ed to the directory I wanted the link in then just let the name of the link be the name of the file, so I didn't need a destination file name, just ln -s source_file
Re:I always forget the argument order of the `ln -s` command by forza on Wednesday December 08, 2010 @05:19PM (#1984881)
In my experience the more variable argument often comes last, presumably for easy reuse. For example...

  $chown user1 file1
  $chown user1 file2

  $ln -s file1 file2
  $ln -s file1 file3
...seems more likely than...

  $chown user1 file1
  $chown user2 file1

  $ln -s file1 file2
  $ln -s file3 file2
Re:I always forget the argument order of the `ln -s` command by eru on Wednesday December 08, 2010 @07:01PM (#1985308)
That's the reason behind a most of the argument orders in the Haskell standard library: To ease Currying.
Re:I always forget the argument order of the `ln -s` command by viraptor on Wednesday December 08, 2010 @07:32PM (#1985392)
Why did you do that? Now I really want to implement a const and flip for text arguments :)
Re:I always forget the argument order of the `ln -s` command by eru on Thursday December 09, 2010 @09:20AM (#1987493)
That could be a nice command line tool. Please include a Data.Function.on, and find a way to make it useful.

flip would actually be quite useful for me on grep. I often search the some corpus of text, but change the pattern.

Re:I always forget the argument order of the `ln -s` command by dkasper on Wednesday December 08, 2010 @05:23PM (#1984904)
This happens to be the first comment in the thread on Reddit.
Re:I always forget the argument order of the `ln -s` command by julian37 on Thursday December 09, 2010 @12:52AM (#1986271)
Exactly. Why the GP's comment is currently at +33 when all it does is restate the main point of the story in a confusing way (by introducing from/to into the mix) is beyond me.
Re:I always forget the argument order of the `ln -s` command by gnosis on Thursday December 09, 2010 @04:28AM (#1986763)
Probably because most of the people upvoting him didn't bother to read the story.

I am often guilty of this myself. At first I used to read all of the stories that were linked to on HN, along with the comments. But I quickly learned that the comments were often much more interesting/useful than the stories themselves.

So now I just look at the comments first, by default. And only in exceptional cases do I actually bother to read the article. There's just not enough time..

HN is an overwhelming firehose of information even without reading every article that seems interesting. But reading the comments can usually quickly give you a good feel for whether the story is worth reading or not. In this particular case, I think not.

Re:I always forget the argument order of the `ln -s` command by socksy on Wednesday December 08, 2010 @10:25PM (#1985880)
Not the most helpful of advice for those that can't remember which way round the cp command takes its arguments either...
Re:I always forget the argument order of the `ln -s` command by orblivion on Wednesday December 08, 2010 @05:32PM (#1984944)
That's what I would have intuitively thought. But I swear it worked the other way sometimes!