News for hackers. Stuff that matters.
Re:Everything I googled in a week as a professional software... by aloknnikhil on Friday September 06, 2019 @01:15PM (#20897542)
On the list of things I always Google, is how to create a symbolic link under Linux. I just can't figure out a way to remember what comes first; the source or the destination. The man pages add to the confusion by calling the "source" the target. So, the rule of thumb I now follow is cp or mv semantics.
Re:Everything I googled in a week as a professional software... by reginaldo on Friday September 06, 2019 @01:21PM (#20897603)
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.
Re:Everything I googled in a week as a professional software... by nikconwell on Saturday September 07, 2019 @05:18AM (#20902713)
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.
Re:Everything I googled in a week as a professional software... by throwaway744678 on Friday September 06, 2019 @02:20PM (#20898261)
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.
Re:Everything I googled in a week as a professional software... by TACIXAT on Friday September 06, 2019 @02:34PM (#20898412)
I just do it the one way, get the error that the destination already exists, then swap them.
Re:Everything I googled in a week as a professional software... by hanspeter on Saturday September 07, 2019 @03:24AM (#20902341)
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.
Re:Everything I googled in a week as a professional software... by skzo on Friday September 06, 2019 @06:09PM (#20900338)
Me too, I was starting to think I was the crazy one after reading the other comments :)
Re:Everything I googled in a week as a professional software... by account42 on Monday September 09, 2019 @04:39AM (#20916256)
Except if b is a directory, then ln -s a b will create a symlink at b/a which points to a.
Re:Everything I googled in a week as a professional software... by taftster on Friday September 06, 2019 @03:10PM (#20898809)
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).
Re:Everything I googled in a week as a professional software... by vehementi on Friday September 06, 2019 @06:33PM (#20900468)
Sounds like you're making bold assumptions about people's beliefs about whether the extra argument would go before or after the existing argument :)
Re:Everything I googled in a week as a professional software... by psutor on Friday September 06, 2019 @01:46PM (#20897860)
That's how I memorized it too! Really struggled with it until I started thinking of it that way.
Re:Everything I googled in a week as a professional software... by Noumenon72 on Friday September 06, 2019 @09:29PM (#20901218)
What do you all use symbolic links for so much that you would need to memorize it?
Re:Everything I googled in a week as a professional software... by munificent on Friday September 06, 2019 @01:24PM (#20897637)
Thank you, this is really helpful.
Re:Everything I googled in a week as a professional software... by aloknnikhil on Friday September 06, 2019 @01:27PM (#20897668)
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.
Re:Everything I googled in a week as a professional software... by anilakar on Saturday September 07, 2019 @04:00AM (#20902459)
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.
Re:Everything I googled in a week as a professional software... by autoexec on Friday September 06, 2019 @04:26PM (#20899566)
and now I've just memorized it myself. Thanks!
Re:Everything I googled in a week as a professional software... by throwaway5d097 on Saturday September 07, 2019 @12:07AM (#20901721)
I think of it like `cp`. Source to destination, where destination is the soft link. so it's like copying a file somewhere but instead of a copy you're making a link
Re:Everything I googled in a week as a professional software... by dpwm on Saturday September 07, 2019 @05:10AM (#20902683)
Same here. After adopting this approach, I haven't had to look it up since.

The real question I have left: why is this so intuitive for cp, but completely counterintuitive for ln?

I wonder if is because we think of how we would follow the link.

Re:Everything I googled in a week as a professional software... by iandanforth on Saturday September 07, 2019 @11:44AM (#20904465)
This. "I want something here that points to there" is how I always think about it. That's why "link" on my boxes is mapped to "ln -s" with the arguments swapped :)
Re:Everything I googled in a week as a professional software... by hnarn on Saturday September 07, 2019 @11:58AM (#20904581)
> I think of it like `cp`. Source to destination, where destination is the soft link.

That doesn't make sense to me. The way I think about cp is "copy this, and put it over here". If you think about symlinks that way, you mix it up.

When you say "source to destination, where destination is the soft link", that makes it more confusing for me, because if you consider the symlink that is being created as the "destination" (which at least is the intuitive way to think about it for me, but I suppose it's individual), you actually end up with:

# cp [source] [destination]

# ln -s [destination] [source]

Where "source" is "the new thing that should be created".

Since I seem incapable of getting out of this way of thinking about sources and destinations, my rule of thumb is that when creating a symlink, you always decide where it should point first. Not intuitive perhaps, but this time I've made the mistake so many times it kinda sticks.

Re:Everything I googled in a week as a professional software... by throwaway5d097 on Saturday September 07, 2019 @02:45PM (#20905699)
If it was a hard link, I suppose my way of thinking about it would make more sense, since all hard links are as valid, pretty much the same. That is, after running

  ln /some/file /other/file
/some/file and /other/file are hard links. So in this case ln is just copying a hard link, while afaik cp would be copying data, making a hard link pointing to the new data. In userspace? That seems to be what's happening here - https://github.com/openbsd/src/blob/master/bin/cp/utils.c

This is made a bit more confusing by the differences in man pages. For GNU ln, it's shown as ln TARGET LINK_NAME, but for OpenBSD, ln source [target]. But the usage is pretty much the same?

Re:Everything I googled in a week as a professional software... by mtm on Saturday September 07, 2019 @03:20PM (#20905901)
how about like this:

# cp [existing-thing] [new-thing]

# mv [existing-thing] [new-thing]

# ln -s [existing-thing] [new-thing]

Re:Everything I googled in a week as a professional software... by rmsaksida on Saturday September 07, 2019 @12:49PM (#20904916)
I do this as well, but it only works if I don't think about it. If I start thinking about it, I begin second guessing myself on whether I got it right and end up having to look it up.
Re:Everything I googled in a week as a professional software... by unoti on Friday September 06, 2019 @03:16PM (#20898887)
> how to create a symbolic link under Linux. I just can't figure out a way to remember what comes first

Remember it like this: It's the same syntax as "cp". To copy a file you use "cp source dest". It's the same for ln: "ln -s source dest"

Re:Everything I googled in a week as a professional software... by rohit2412 on Friday September 06, 2019 @03:42PM (#20899173)
I always think of links as pointing from source to destination. Your way would break that intuition for me. It would be the source of the address and the destination for the address to be copied to.
Re:Everything I googled in a week as a professional software... by bonoboTP on Friday September 06, 2019 @04:36PM (#20899649)
Remember it like this: just as in cp, the file that already exists comes first, the file/link we are creating now comes second.
Re:Everything I googled in a week as a professional software... by unoti on Friday September 06, 2019 @03:46PM (#20899216)
I understand fully; that’s also how I thought of it for years and why I couldn’t ever remember it. But if you think about it like copying a file it’s easier to remember. And it is like copying a file— it’s copying a reference to a file.
Re:Everything I googled in a week as a professional software... by Izkata on Friday September 06, 2019 @06:01PM (#20900297)
Try taking the command a step back with hardlinks: ln source dest

The association with cp makes a lot more sense then. This is how I learned it.

Re:Everything I googled in a week as a professional software... by dmoy on Friday September 06, 2019 @01:49PM (#20897904)
Given the number of things that use different source vs destination with the same type, I just have trained myself to always look it up, even if I am 99% sure I remembered it correctly, because holy shit when you get it wrong sometimes it's bad.

softlink dest <- src

file cp src -> dest

std::memcpy dest <- src

java arraycopy src -> dest

golang io.Copy dest <- src

etc etc

I'm only 80% confident I didn't make an error in the above 5 examples...

Re:Everything I googled in a week as a professional software... by EliRivers on Friday September 06, 2019 @02:24PM (#20898298)
Intel assembly: mov dest, src

AT&T assembly: mov src, dest

Whenever I'm debugging at the assembly level I have to just write down the appropriate one on a piece of paper in front of me.

Re:Everything I googled in a week as a professional software... by dmoy on Friday September 06, 2019 @02:29PM (#20898365)
at least arm and mips both match x86 (right? unless I forgot. probably I forgot, it's been over a decade)
Re:Everything I googled in a week as a professional software... by nostoc on Friday September 06, 2019 @02:47PM (#20898574)
Both of the parent's examples were in x86, intel and AT&T are only syntaxes for the same thing.
Re:Everything I googled in a week as a professional software... by grumdan on Friday September 06, 2019 @02:48PM (#20898585)
Well two differing conventions above are both for x86, so you can't "match x86".
Re:Everything I googled in a week as a professional software... by saagarjha on Friday September 06, 2019 @02:26PM (#20898323)
I've heard that C's src/dest parameter order is supposed to match assignment.
Re:Everything I googled in a week as a professional software... by freetonik on Friday September 06, 2019 @01:44PM (#20897833)
What came first: the file or the symlink? Of course the real file came first!

Mnemnic that helps me: IN SYMLINKS, REAL FIRST!

ln -s REAL_FILE link_name

Re:Everything I googled in a week as a professional software... by wereHamster on Friday September 06, 2019 @01:59PM (#20898025)
I know of two different ways to remember:

1. Same as mv: `mv REAL_FILE link_name`

2. The second argument is optional. Therefore, the first argument must be the real file, and the second the link name. It does not make sense to omit the real file.

Re:Everything I googled in a week as a professional software... by huherto on Friday September 06, 2019 @02:07PM (#20898098)
This. Same as mv AND cp.
Re:Everything I googled in a week as a professional software... by inimino on Friday September 06, 2019 @04:34PM (#20899631)
Two minor points: They are both real files. The symlink may be created first.

"Source" and "target" are confusing names because the target of the ln command is the file it creates, which is the symlink that points to the source file, which is the "target" of the symlink in an intuitive sense. The mnemonic works because it matches mv and in that case the file that exists must obviously come first. In ln without -s the file also must exist, which makes perfect sense. So it's easy enough to remember if you understand what the ln semantics are and don't get hung up by the source and target jargon.

Re:Everything I googled in a week as a professional software... by miclol on Friday September 06, 2019 @01:24PM (#20897634)
I used to Google that a lot. But now I make an analogy with "cp", the second argument being the file that is been created (the simlink in this case)
Re:Everything I googled in a week as a professional software... by inimino on Friday September 06, 2019 @04:45PM (#20899724)
Reading the man page instead of Googling this will make you a better engineer, and it will also cost more of your time while you figure out what the man page is trying to say. This knowledge may save you time later, if you use it again, or not. So the advice I would give is, never Google if the answer can be found in the man page. Unless it's a tool you're unlikely to ever use again, of course.
Re:Everything I googled in a week as a professional software... by jplayer01 on Saturday September 07, 2019 @10:58AM (#20904121)
Man pages are so insufferably long and mostly irrelevant though. It's come up on HN before, I think, how if you're ever looking for anything specific like commonly used arguments and common usages, it's a complete waste of time to go through an entire man page.
Re:Everything I googled in a week as a professional software... by inimino on Saturday September 07, 2019 @01:25PM (#20905198)
Except that, if you think about it, every sentence in a well-written man page was put there by an absolute expert in the tool who thought you might need to know it. If you want to master your tools, it's absolutely not a waste of time to read the friendly manual. When you use a system professionally every day and refuse to read the manuals because it takes too long, and you're in way too much of a hurry, you're only hurting yourself in the long run.

You're probably going to notice the time you spend reading man pages, when you just! want! to! get! something! done! And that's frustrating. What you're less likely to notice is the next five times you reach for the wrong tool, or have to go hunting around for some bubble-gum-and-twine way to do something, because you didn't previously read the man page that tells you exactly what you needed to know to do it easily and correctly.

Re:Everything I googled in a week as a professional software... by jplayer01 on Saturday September 07, 2019 @02:56PM (#20905770)
Well, no. Even if I read the damn thing, there are tens of tools I use day to day. I'm not going to remember any of it. It doesn't matter how much of an expert the author was if it's not structured in a useful way. And I've read enough fucking man pages. I've retained zero except for maybe what I ended up using. If I used it more than once. Maybe. Man pages don't tell you shit. They tell you everything and you still need to parse, interpret and analyze it because it's so ridiculously dense and there's never any guidance on actual real-world usage. Theoretically they're useful, realistically, they completely ignore everything about how human beings function. They're not written for people.

Hell, I often find that while the author has managed to cram everything and the kitchen sink into it, there's so much missing from it regarding how a tool works, caveats, whatever. All these things that are crucial to actually understanding the tools you're using beyond what some flag or other does on a surface level.

Re:Everything I googled in a week as a professional software... by inimino on Saturday September 07, 2019 @04:31PM (#20906326)
Reading, interpreting, and using dense technical documentation is a skill, just like reading maths. If you don't get anything out of it, maybe this is a skill you are presently lacking and something you should improve. Taking notes on what you are doing and reviewing your initial guesses, resources consulted, and eventual solutions may help you consolidate this ad-hoc knowledge into understanding.

I've read many man pages, many many times, and if I get nothing out of it, I find it is invariably because I am in a hurry, and I'm probably about to fuck something up. The thing to do is usually to slow down and do it right. Only rarely is the right thing to ask someone else for the solution, or see what some other poorly-informed person on the internet thought, although in an emergency asking for help is almost always the right call.

A huge amount of what man pages don't tell you is general Unix philosophy. Man pages don't tell you the lore around the thing, they describe the implementation. It's up to you to infer the consequences and how it can be used. Man pages don't hide the underlying bones of the system either, and generally assume you're comfortable writing a C program to test a syscall if you're not sure about something. So sure, reading man pages isn't always easy, but neither is getting regular exercise or eating your vegetables.

Re:Everything I googled in a week as a professional software... by jplayer01 on Saturday September 07, 2019 @07:16PM (#20907322)
You're insufferable like every other Linux elitist out there. You realize being polite while being an arrogant prick doesn't change how much of an asshole you are being? I hate this kind of bullshit and I'm tired of it. And I'll get warned because I'm the one getting mad over it. Fuck this shit.
Re:Everything I googled in a week as a professional software... by inimino on Sunday September 08, 2019 @03:21PM (#20912743)
I know it sucks when your environment sucks and your tools suck and people tell you your habits suck too. I can tell you're frustrated by your tone in this thread even before I told you that you may lack the skill of slowing down enough to read technical documentation. So, you're right. I'm telling you to be better and try harder, and I don't even know your situation! Maybe that does make me an asshole. Certainly most people higher on "agreeableness" than I am wouldn't say those mean things.

By the way: I might be a Linux elitist, but nobody's ever called me that. I use OS X in my day job. I've been programming in some capacity for about 30 years. Your mileage may vary. If you take my advice you may hate me for it, but it will almost certainly make you a better developer in the long run. And I don't mind if you think I'm an asshole. I know I'm right, and you probably know I'm right too.

Finally, if we weren't having this interaction in public, I'd be kinder, gentler, and might not say anything at all. But if one other person who hates reading difficult technical material is pushed to overcome that limitation by reading this thread, it's worth it, even if it means making you mad.

And just in case you're still reading, in addition to reading man pages, and taking notes, here are the other things you should be doing:

Preferring textbooks over blog posts and youtube videos to learn a new field.

Reading original research by pioneers in the field, like Turing, Shannon, etc, rather than their main findings rehashed by lesser minds.

Reading source code rather than jumping from documentation to Stack Overflow when something doesn't work.

Reading Knuth on algorithms, Stevens on Unix networking, etc. In other words, read the classics that everyone says you should read but most people don't. Work through the exercises. It's the closest thing to an actual superpower.

Look around for people better than you at all this stuff to help you improve.

Good luck!

Re:Everything I googled in a week as a professional software... by hyperdimension on Friday September 06, 2019 @02:15PM (#20898200)
This is how I remembered it: Look, it's just like ''cp'', except you're making a symlink, not a copy.
Re:Everything I googled in a week as a professional software... by mlaretallack on Friday September 06, 2019 @01:32PM (#20897706)
Same here.

Its one of those things that after almost 20 years, I should remember. But it just does not go in.

It becomes interesting when junior programmers are watching how I do something and I end up googl'ing things that they know.

I use the excuse that it fees up more space for other more interesting stuff, a bit like some execs just ware T-shirt and jeans to reduce the number of things to distract them in the morning so that can concentrate on the important things.

Re:Everything I googled in a week as a professional software... by taneq on Saturday September 07, 2019 @04:58AM (#20902649)
There's a reason for the saying "the master has forgotten more than the journeyman has ever learned." :P
Re:Everything I googled in a week as a professional software... by asdffdsa on Friday September 06, 2019 @01:35PM (#20897745)
"it fees up more space for other more interesting stuff"

I see you take a similar approach to spelling

Re:Everything I googled in a week as a professional software... by uhhyeahdude on Saturday September 07, 2019 @02:23AM (#20902130)
Your punctuation choices are also executive level.
Re:Everything I googled in a week as a professional software... by mlaretallack on Friday September 06, 2019 @03:38PM (#20899122)
Yep.
Re:Everything I googled in a week as a professional software... by dev_dull on Friday September 06, 2019 @01:41PM (#20897804)
I believe it's a specific POSIX standard that CLI tools are always in the same order: source -> destination[1]

ln, cp, mv, most everything will always follow this pattern.

https://www.gnu.org/software/swbis/sw.html#o-Explicit-File-D...

Re:Everything I googled in a week as a professional software... by snippyhollow on Friday September 06, 2019 @01:33PM (#20897721)
It is like `cp`.
Re:Everything I googled in a week as a professional software... by loosescrews on Friday September 06, 2019 @01:55PM (#20897972)
It isn't just like `cp`, on some systems `ln` is just a symlink to `cp`! `cp -s` does the same thing as `ln -s`, although the other flags are generally different.
Re:Everything I googled in a week as a professional software... by 384028345 on Saturday September 07, 2019 @04:36AM (#20902576)
You might like the tldr program:

$ tldr ln

ln

Creates links to files and directories.

- Create a symbolic link to a file or directory: ln -s path/to/file_or_directory path/to/symlink

- Overwrite an existing symbolic to point to a different file: ln -sf path/to/new_file path/to/symlink

- Create a hard link to a file: ln path/to/file path/to/hardlink

Re:Everything I googled in a week as a professional software... by OJFord on Friday September 06, 2019 @02:51PM (#20898624)
This is used to really confuse me too, but now I can't remember why, because everything's the same:

  touch <destination...>
  $EDITOR <destination...>
  mv <current...> <destination>
  cp <current...> <destination>
  scp <current...> <destination>
  mount <current> <destination>
 
The place you're putting something is last in each case; we can even include everything that doesn't modify its location.

All I can think of that breaks the rule is `rm`, `unlink`, and `umount`. But they're hardly gotchas, and they're not reversing arguments they just don't have a 'destination'.

Re:Everything I googled in a week as a professional software... by meow1032 on Friday September 06, 2019 @03:32PM (#20899062)
I think "zip" breaks this rule.
Re:Everything I googled in a week as a professional software... by hibbelig on Saturday September 07, 2019 @08:05AM (#20903266)
Zip is a DOS tool, so I’m not so surprised it’s not following Unix conventions...
Re:Everything I googled in a week as a professional software... by efreak on Saturday September 07, 2019 @02:08AM (#20902098)
That's because with zip (and tar, and other archivers) you can have multiple items to move to a destination archive.

You can also do that with cp and mv if you need to, using `-t`. `cp -t .dotfiles/ .nanorc .bash*`. Generally more useful when you want to move a bunch of files around.

Re:Everything I googled in a week as a professional software... by OJFord on Saturday September 07, 2019 @05:11AM (#20902688)
The `...` in my post above was to indicate that.

Zip does indeed break the 'rule', but this is not an excuse, cp and mv manage just fine with:

  in in in in [...] out
Which is why I said the 'last' rather than 'second'.
Re:Everything I googled in a week as a professional software... by neop1x on Monday September 09, 2019 @05:56AM (#20916699)
I think 'ln' as a tool which creates a symlink. And symlink is a new object, a new kind-of file. So it must be the last argument. The source is just an attribute of that symlink "file" holding the path it points to. If I want to overwrite an existing symlink "file", I simply add -f meaning force-overwrite-if-the-symlink-file-already-exists.
Re:Everything I googled in a week as a professional software... by elviejo on Friday September 06, 2019 @01:53PM (#20897948)
I couldn't remember also. The way I finay did it was to memorize 'ln -s -T' -T stands for target that way... I know the next thing must be the target then the source.
Re:Everything I googled in a week as a professional software... by arminiusreturns on Friday September 06, 2019 @11:39PM (#20901650)
If you google/duckduck go something more than once, I think it should be put into documentation. I have one central org file where I keep that majority of my one off questions about a tool, and these days I look there often first before man or info because I have condensed the information into something faster to parse for me.

Right now my main battle is deciding to port docs like this into asciddoc(tor) or keep them in org, both being exported to html5 eventually.

Re:Everything I googled in a week as a professional software... by red75prime on Friday September 06, 2019 @04:59PM (#20899840)
Busybox's ln --help is straight to the point

  Usage: ln [OPTIONS] TARGET... LINK|DIR
  Create a link LINK or DIR/TARGET to the specified TARGET(s)
Re:Everything I googled in a week as a professional software... by the8472 on Friday September 06, 2019 @01:24PM (#20897632)
I always type ln -sT ..., which then helps me remember which one is the target of the link.
Re:Everything I googled in a week as a professional software... by TaylorAlexander on Friday September 06, 2019 @08:14PM (#20900958)
I search (duck duck go) for this constantly. For a couple of days last week I remembered it, but it’s always helpful to check. Some day I should see what happens if I get it backwards. Probably it will say no and that’s it. If that’s true then I can just try until it works!
Re:Everything I googled in a week as a professional software... by taesko on Saturday September 07, 2019 @02:47AM (#20902192)
I remember it by first remembering that it is possible to not provide the destination (ln /.../file) to create a symlink with exactly the same name in the current directory. So it has only 1 required argument which always has to be first.
Re:Everything I googled in a week as a professional software... by Rapzid on Friday September 06, 2019 @03:27PM (#20899005)
Well, you're linking TO something and not FROM something so target seems more accurate(they are essentially pointers).

I'm honestly surprised about the help confusion though:

ln --help Usage: ln [OPTION]... [-T] TARGET LINK_NAME (1st form)

Re:Everything I googled in a week as a professional software... by inimino on Friday September 06, 2019 @04:39PM (#20899675)
That is the symlink target, not the ln target, which is exactly why the "target" nomenclature is confusing. Also note that not every "ln" has a "--help" or uses that help message as the output. For example, try on OS X `/bin/ln -h`.
Re:Everything I googled in a week as a professional software... by Rapzid on Friday September 06, 2019 @04:59PM (#20899836)
Yes, it would be platform specific as the OSX ln command would not be the same program as the GNU coreutils ln program.

For GNU ln at least I don't find it confusing at all particularly considering the only other option is LINK_NAME. I guess YMMV though and it seems kinda pointless to argue whether it is or is not confusing. Perhaps a poll could quantify it.

Re:Everything I googled in a week as a professional software... by inimino on Friday September 06, 2019 @07:35PM (#20900817)
If "target" is used to mean two different things in the same context, it is going to confuse people! This is why naming things is hard!
Re:Everything I googled in a week as a professional software... by Rapzid on Saturday September 07, 2019 @12:22AM (#20901763)
In GNU coreutils ln help and man page it only ever uses TARGET to refer to the link target?
Re:Everything I googled in a week as a professional software... by inimino on Saturday September 07, 2019 @01:35AM (#20901997)
I wasn't speaking specifically about GNU. Note though that even there you see a --target-directory, -t, -T flags that make literally no sense anymore once GNU reversed the meaning of the term.
Re:Everything I googled in a week as a professional software... by parliament32 on Friday September 06, 2019 @02:20PM (#20898262)
Honestly I gave up memorizing when I realized you can just omit the second parameter.

    ln -s /the/real/thing
will create a symlink in your current directory with the same name.
Re:Everything I googled in a week as a professional software... by martin-adams on Saturday September 07, 2019 @12:06PM (#20904635)
About 15 years ago a colleague of mine at IBM had the following on their board.

ln -s physical virtual

I never forgot it and can see it visually in my mind. You need something physical before you can virtualise it.

Re:Everything I googled in a week as a professional software... by senozhatsky on Saturday September 07, 2019 @08:49AM (#20903452)
I pretend that '-s' stands for "source", not "symbolic"; and source file follows -s(ource) option. IOW `ln -s A B' is `link source A to B'.
Re:Everything I googled in a week as a professional software... by xelxebar on Saturday September 07, 2019 @06:27PM (#20907033)
Thinking like this, it fits the pattern of other coreutils tools:

    $ mv existing_path new_path
    $ cp existing_path new_path
    $ ln existing_path new_path
Re:Everything I googled in a week as a professional software... by flatline on Friday September 06, 2019 @01:48PM (#20897893)
I remember it as FROM source, TO target, so the real file comes first
Re:Everything I googled in a week as a professional software... by 725686 on Friday September 06, 2019 @02:17PM (#20898220)
I totally get that you don't remember what goes first, it happens to me with tons of commands... but googling it? Why don't you just execute the command and see if it worked?
Re:Everything I googled in a week as a professional software... by zikani_03 on Friday September 06, 2019 @03:33PM (#20899073)
Haha, glad to see I'm not the only one who struggled with remembering this. I always refered to a task in a fabfile to remember. +1 for "follow cp or mv semantics"
Re:Everything I googled in a week as a professional software... by iforgotpassword on Friday September 06, 2019 @02:14PM (#20898185)
There are some clever tips here how to remember. Ages ago I struggled too so for half a day I just kept repeating the words "ln target linkname" in my head. Anyone else?
Re:Everything I googled in a week as a professional software... by jplayer01 on Saturday September 07, 2019 @10:56AM (#20904110)
I feel like a lot of this stuff is rote memorization that we shouldn't be so eager to demonize. The medical profession has you memorizing effectively random shit for years and that's fine. But in our industry, we think we should just magically remember stuff we enter once in a blue moon, and if not, who cares, just Google for it. It bothers me. And it's something I've increasingly turned to flash cards for. I'm tired of googling that command I used once 3 months ago but would be insanely useful right now.
Re:Everything I googled in a week as a professional software... by soulofmischief on Friday September 06, 2019 @02:37PM (#20898457)
The infuriating thing is that Windows' mklink does it the other way around... link, then target. It took me years to stop RTFM every single time I'd user mklink/ln
Re:Everything I googled in a week as a professional software... by justmyname on Friday September 06, 2019 @01:25PM (#20897649)
I have remembered the order of arguments since I figured out that the second argument is optional. So the link name is of course optional, not the original file's one.
Re:Everything I googled in a week as a professional software... by bb88 on Saturday September 07, 2019 @02:07AM (#20902095)
In the old days there was just 'man ln'
Re:Everything I googled in a week as a professional software... by afabisch on Saturday September 07, 2019 @03:58AM (#20902452)
Yes, you don't need to switch to a browser.
Re:Everything I googled in a week as a professional software... by tiborsaas on Friday September 06, 2019 @01:48PM (#20897885)
I still couldn't do it on the command line, probably cheating, but Midnight Commander shortcut is CTRL-X-S :)
Re:Everything I googled in a week as a professional software... by ChuckMcM on Friday September 06, 2019 @02:16PM (#20898212)
It bothered me as well, my mnemonic became "link to <this target> using <this link name>"
Re:Everything I googled in a week as a professional software... by harubbba on Saturday September 07, 2019 @05:38AM (#20902779)
All gnu command line tools are the same in this regard: SOURCE DESTINATION.

    ln -s src dst
Re:Everything I googled in a week as a professional software... by ihaveajob on Saturday September 07, 2019 @10:36AM (#20903991)
I read `ln -s A B` like "link A as B", and it tends to work with most Unix commands.
Re:Everything I googled in a week as a professional software... by eric_h on Friday September 06, 2019 @04:12PM (#20899454)
I found remembering that it's the same as `cp` is what stopped me from continuously googling it.
Re:Everything I googled in a week as a professional software... by latortuga on Friday September 06, 2019 @03:11PM (#20898829)
It finally clicked with me when I read about it as ln -s real fake

Real is always better than fake, real comes first.

Re:Everything I googled in a week as a professional software... by taneq on Saturday September 07, 2019 @05:01AM (#20902660)
Works for typedefs too.
Re:Everything I googled in a week as a professional software... by fukyall on Sunday September 08, 2019 @10:09AM (#20910627)
The best way to remember it is that only the first argument is mandatory.
Re:Everything I googled in a week as a professional software... by 19ylram49 on Friday September 06, 2019 @03:42PM (#20899164)
I just search my shell history for that one, because I can never remember either!
Re:Everything I googled in a week as a professional software... by jdc on Friday September 06, 2019 @02:00PM (#20898030)
For simple shell commands like this, tldr is really handy.

https://tldr.sh

Re:Everything I googled in a week as a professional software... by methehack on Friday September 06, 2019 @01:56PM (#20897980)
fwiw, I always say outloud in my head "thing that exists first" -- but I did need a mnemonic. Somehow I didn't realize it was just cp semantics.
Re:Everything I googled in a week as a professional software... by jnurmine on Friday September 06, 2019 @02:12PM (#20898154)
My memory aid is "link file as linkname".
Re:Everything I googled in a week as a professional software... by cos2pi on Friday September 06, 2019 @01:48PM (#20897894)
I'm the same way with scp, I never remember the order and then it changes if you're uploading or downloading.

Also, an obligatory xkcd: https://xkcd.com/1168/

Re:Everything I googled in a week as a professional software... by dllthomas on Friday September 06, 2019 @02:11PM (#20898147)
I don't understand where the confusion is with scp. It's just like cp, except you have a syntax for making some of the arguments remote. It doesn't change the order, it always does semantically the same thing of moving something(s) somewhere.

This is not to criticize - we all have places our mental models break down unexpectedly. I'm just interested in how that's happening.

Re:Everything I googled in a week as a professional software... by heavenlyblue on Friday September 06, 2019 @03:07PM (#20898776)
I find scp really easy. rsync, on the other hand, is like tar to me.
Re:Everything I googled in a week as a professional software... by shiftpgdn on Friday September 06, 2019 @03:08PM (#20898785)
Easy way to remember extracting with tar is "eXtract Zee Files" -xzf.
Re:Everything I googled in a week as a professional software... by efreak on Saturday September 07, 2019 @02:15AM (#20902113)
I no longer have issues with tar since I found out that most systems I use don't need the compression format anymore, and are happy to figure it out themselves. Not sure if it works with compressing or not (I generally use 7z or zip), but you can just `tar -x[v]f` on anything, regardless of file extension, and tar will extract anything it supports.
Re:Everything I googled in a week as a professional software... by Barrin92 on Friday September 06, 2019 @01:50PM (#20897920)
i've personally given up on this after googling it a dozen times and now i just cd into the target directory first and omit it
Re:Everything I googled in a week as a professional software... by wcchandler on Friday September 06, 2019 @05:43PM (#20900194)
link -s this (to) that

This has to exist... but that doesn’t.

Re:Everything I googled in a week as a professional software... by meddlepal on Friday September 06, 2019 @11:53PM (#20901685)
Hah, I thought I was the only one!
Re:Everything I googled in a week as a professional software... by pw6hv on Friday September 06, 2019 @03:52PM (#20899277)
ln -s actual link

Read it somewhere long time ago, never had to look for it again :)

Re:Everything I googled in a week as a professional software... by tejtm on Saturday September 07, 2019 @04:32AM (#20902563)
it is the same as copy first `from` then `to`
Re:Everything I googled in a week as a professional software... by bayonetz on Monday September 09, 2019 @10:53AM (#20918734)
I love the man replacement packages like tldr, bro, etc. for exactly these kinds of simple, yet easy to forget incantations.