Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Here's how I finally memorized it: ln has a 1-file-argument invocation, so ln -s ../../a_fine_file will create a symbolic link to that file under the current directory and under the "a_fine_file" file name. The single argument case has to have the file you want to link to as input. That generalizes nicely as the 2-file-argument invocation maintaining the logic.


A guy in the office always remembers it as remembering that wedding saying - something old, something new, something borrowed, something blue. Whenever he did a symlink he would always say out loud something old, something new, ... That has stuck with me as well for all these years so I've never needed to figure out which was which, I always just knew it.


Ha! My trick is to

  ln -s a b
then look at the link with ls -l, then remove my garbage! Your way is much better.


I just do it the one way, get the error that the destination already exists, then swap them.


I think most people just feel this is risky. What if you overwrite your file? If it was a cp command, that's what would happen.


Me too, I was starting to think I was the crazy one after reading the other comments :)


Except if b is a directory, then ln -s a b will create a symlink at b/a which points to a.


Yup, exactly. I always use the form:

  ln -s ../../a_fine_file .
With the added '.' at the end. That way, I can remember to change the period out if I don't want the same name (or if I'm linking in the same directory).


Sounds like you're making bold assumptions about people's beliefs about whether the extra argument would go before or after the existing argument :)


That's how I memorized it too! Really struggled with it until I started thinking of it that way.


What do you all use symbolic links for so much that you would need to memorize it?


Thank you, this is really helpful.


Interesting. Thanks, that's helpful. It's also a necessary approach for using relative paths as targets when you refer to the current directory to add the link in.


I use a similar rule for those git commands that either take one or two branch names. The latter one must obviously be the current branch by default.


and now I've just memorized it myself. Thanks!




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: