Conversation
I've been admining Linux systems for 25 years, and I still have to check which one it is every time.
242
994
1873

@monsieuricon I have a tip: you can omit the second argument, in which case the written filename is deduced from original file. So the second argument is the link. HTH?

7
0
0
@monsieuricon Weird. To me it's always "origin" "destination".

My main issue is when using relative paths for symbolic links, because you may get unexpected results.
2
0
0

@monsieuricon Most of the time I fall for it, too :D

Sometimes I can remember that you NEED a target, but linkname is optional

0
0
0
@monsieuricon I got around this by thinking of ln as a rename that doesn't remove the old file. And, indeed, they are the same program underneath.
1
1
17

@waltercool@pl.slash.cl @monsieuricon@social.kernel.org if you spell it out, you're linking path $2 to path $1, so it's possible to think of $1 as the destination.
a nicer hint is to remember $2 is optional, because it makes sense to have it be $PWD.

0
0
0

alina🏳️‍🌈🏳️‍⚧️ (floofy doggo girl)

@monsieuricon obviously like target nickname because it works just like mount

0
0
0

@monsieuricon I try to remind it by
ln -s from to

3
0
0

@monsieuricon @uliwitness “the same as cp”

(not that I don’t have to remind myself of that, but)

2
0
0
I appreciate people saying that it's like `cp` or `mount`, but in my head the natural order of thinking about this operation is reversed: it's "create a link to this file" not "make this file also known as this link." Hence two competing "gut feelings" about which should come first. It also doesn't help that commands like "alias" work the opposite direction ("make a new command that is actually this another command").

Anyway, it was really just an observation that I confuse this all the time, and I'm not the greenest Linux admin around. :)
21
12
124

@monsieuricon yeah, it is funny that it is always "from to", when you create link "FROM_target (<-) TO_link_name", but when you list files you get "FROM_link_name -> TO_target"

EDIT: s/target/source/ sounds better in the first case when you create link

0
0
0
To be fair that is horrible terminology.

I remember it as source/input first, to/output last.

Which intuitively feels like the natural flow of things to me.
0
0
0

@waltercool @monsieuricon it stuck with me with "Source[code] first, always!!11eleven" 🤓

0
0
1
@monsieuricon i think of it as an html hyperlink
<a href="link">link</a>
0
0
0
@monsieuricon I raelly believe there are certain types of information that plop out of your brain immediately after you acquire them and this is one of them lol
0
0
4

@monsieuricon @jalefkowit I rely on muscle memory - to say, I had to quickly go into a shell and start typing and see which one felt most natural. And yes, that one was the order. 😂

1
0
0

@monsieuricon I've memorized it with 'create a link from here to there'

0
0
0

@ics@tau-ceti.space @monsieuricon@social.kernel.org @jalefkowit@octodon.social this is what i do too. if i think about it too hard, i get it wrong. if i just vibe it out, it usually comes out right.

0
0
0

@monsieuricon
For me, ln -s src dest
and the source always comes near the '-s'
It helps that I usually 'ls src' to check the path, and then edit that command to insert 'n -', before putting the destination at the end.

0
0
0

@monsieuricon Related: rsync and where to put the * or the /

2
0
0

@monsieuricon IDK any program that doesn't demand $source $destination as parameters in that order...

So ofc the target is the destination...

2
0
0

Nuncio Bitis 🏳️‍🌈 🇵🇸 🇺🇦

@monsieuricon
EVERY TIME!!!!!

0
0
0

@monsieuricon

People at Microsoft evidently agreed with you. Windows' `MKLINK` command has the opposite order from `ln`.

0
0
0

@monsieuricon The one that always gets me is rsync. Do I put a slash on the end of a directory or not? Decades, and I still often either look it up or end up with the wrong thing and have to clean up.

4
0
0
@kkarhan I'm happy that it works in your head, but in my head linkname is not destination, it's a shortcut *to* the destination.
2
0
5

@monsieuricon @jalefkowit do not consider myself an admin BUT SAME (since Mac OS X 10.0)

0
0
0

@monsieuricon I fixed this for myself by repeating the idea that it's like "hey YOU... come HERE..." -- that is, I need to reference WHO I'm talking about before I can ever make a link. The rest flows from there. :D

So far, it's worked out fairly well. Thankfully. Such a constant irritant before that. 😩

0
0
0
@williampietri the way to brute-force your way out of this confusion is to always end directory paths with '/.':

rsync -avP source/. target/.
0
1
3

@monsieuricon it's obviously $source $destination...

$source = ./linkname
$destination = /path/to/target

1
0
0

@monsieuricon @drahardja I know right away it’s the one on the left and I will always try the one on the right first.

1
0
0

@monsieuricon One of the reasons for such cryptic syntax is that Unix pioneers had to work with teletype terminals.

0
0
0

@monsieuricon
thank you, now I dont feel so alone. I'm been using linux since v1.1.59

0
0
0

@monsieuricon I have nightmares about this one

0
0
0

@monsieuricon @williampietri I add a -n for a dry-run, then look at the output and correct accordingly.

I do this every time since after 20 years I always forget what to do with the /.

0
0
0

@monsieuricon I just use a memory rule of "what to where".

What however is the evilest thing in command line tools, was in some partition management tool (sgdisk?) when cloning partition tables.

It broke the holy command line order and was like "command /dev/target /dev/source".

And yes, I had to learn it the hard way back in the days.

0
0
0

@monsieuricon i just have a "ln -s src dest" in my history

or in general i look at tldr pages (honestly very useful if i forget stuff like that)

0
0
0

@monsieuricon the way i remember it is to imagine im using `cp` to copy the file, except instead of copying, im creating a link. so, ln -s target linkname

0
0
0

@monsieuricon Pretty much the same, for a bit longer. The Dr. Suess-level mnemonic I came up with is along the lines of "One Fish, Two Fish": Old File, New File. It works for me.

0
0
0

@monsieuricon @GrumpusNation

so the way I remember this? if you don't specify a link name, it creates the symlink in the current working directory. Thus, the workflow that supports this is to have the target first.

1
0
0

@monsieuricon Some time ago I memorized `ln -s old new` and this always worked...

0
0
0

@monsieuricon yup, 30 years of Unix/Linux daily use and I still fail this one. Reminds me of USB Type-A 50% chance of plugging it wrong, but failing it *every* time.

BTW, @bagder started a separate thread on this and people are mostly getting it right on the first try - smh...

https://mastodon.social/@bagder/112220659572117434

2
0
0

@monsieuricon funny enough, this appears in my timeline RIGHT NEXT to https://mastodon.social/@bagder/112220659572117434

0
0
0

@monsieuricon someone once pointed out to me that ln takes its arguments in the same order as cp - it just creates a link instead of a copy - and it's been easy to remember ever since

0
0
0

@monsieuricon I just gave up remembering the order of arguments. Every time I need to create a symlink, I just cd into the directory and use the single-argument form. This way the only reasonable argument is the source file.

2
0
0

@monsieuricon I don't have THAT problem (symlink parameter order) unless I stop to think about it, but I did dump a bunch of files into the parent of the directory I had intended to with DOS XCOPY the other day.

0
0
0

@monsieuricon i always do ln -s /path/to/linkname; mv linkname the_name_i_want

1
0
0

@monsieuricon i remember it by saying its the same order as cp

0
0
0

@monsieuricon Every time, it's "ln --help" first. Can never remember!

0
0
0

@monsieuricon
ln -s is like cp.

cp fromtarget dest
ln -s fromtarget tolinknamd

1
0
0

@monsieuricon @hypebot Just drop the second argument. It’ll link to that thing over there to here, with the same file name. The second argument is optional means it can’t be the source, it must be the target.

0
0
0

🐧DaveNull🐧 ☣️pResident Evil☣

@monsieuricon I had the same issue for a while.

Especially since I rarely use ln. I try to convince my brain that "-s" would mean "source" even though I know it actually means "symbolic link", just so I remember that the first argument right after the "-s" option is the existing, "source" file.

1
0
0

@monsieuricon It works just like `cp` source then destination. That's how I remember it.

0
0
0

@monsieuricon 100%. Saying it’s like cp is not helpful as my mental model is the link going the other way (i.e. a link that points to the real file)

0
0
0

@monsieuricon With time everything will fit in place, your gut feelings will be gone, and ln will behave like cp.
(BTW: alias is different: it has a single parameter that is an assignment)

1
0
0

@monsieuricon don't worry you're in very good company

0
0
0

@monsieuricon
Every time 😁
(29 yrs)

0
0
0

@monsieuricon Best thing if you administer both Windows systems and Linux systems: mklink does it one way, and ln does it the other way. But which one does which? neocat_googly_shocked

1
0
0

@monsieuricon Oh gods it's not just me! I've felt like a complete idiot for this.

0
0
0

@monsieuricon

Yep. I have to sit back and think, "it's like cp" and take a deep breath and then I'm okay.

0
0
0

@monsieuricon

Yeah, when I say it's like cp, that doesn't mean it's intuitive. I just have to repeat the mantra.

0
0
0

@monsieuricon I for one suffer the same but because I remember it is the other way around a get confused and have to look :) If there was a system wide config to set it in one of the ways!

0
0
0

@monsieuricon
All proper *nix commands use the syntax.
Command what_already_exists what_you_are_creating

1
0
1

@monsieuricon This is what /tmp is for.

0
0
0

@monsieuricon 100%

I've been cheating for decades by doing `cd target_path; ln -s source`

0
0
0

@monsieuricon @uliwitness I remember that it has the same interface as cp(1):

ln [-s] entry_that_exists entry_that_will_exist_after

0
0
0
@monsieuricon the file to be created goes last.
0
0
0

@monsieuricon Every.
Single.
Time.
Still to this day, after nearly 20 years as a Linux admin 😄

0
0
0

Firstly, plain "ln" without "-s", and not crossing file system boundaries, is like "mv" without the remove part. You end up having the same file twice, in two directories, or different names in the same, symmetrically, no original and no copy. Doesn't work on directories, though.

Secondly, "ln -s" is like "ln", only the result is not symmetric, but then, it may cross file system boundaries and point to directories.

So if you remember how to use mv, you're fine.

@hennichodernich @monsieuricon

1
0
0

@monsieuricon @dan ok, this is TERRIBLE, but I heard it once about 20 years ago and I’ve had zero trouble with ln ever since.

Think of boobs: Everyone prefers real to fake.

Voila.

ln -s real fake

1
0
0

A trailing slash in rsync hides the name before it, so it becomes an anonymous directory and only content counts.

That idea somehow helps me to figure it out.

@williampietri @monsieuricon

0
0
0
@monsieuricon Brother, please. It's always "cmd OLD NEW".
0
0
0

@sidawson @monsieuricon thing is that makes sense, in terms of how cp mv etc work. Yet it's somehow non-obvious

1
0
0

@denix @monsieuricon @bagder Oh, it's more than that. You have to try 3 times to plug in USB-A. And it's the same for ln. Neither order works the first time.

0
0
0

@monsieuricon Every. Single. Time.

0
0
0

@monsieuricon looking at this meme made me forget which order it should be.

0
0
0

@monsieuricon (25+ years) What could possibly go wrong ? =)

(disclaimer: I abuse -s badly)

0
0
0

@monsieuricon I 100% agree with you. I get confused every time I create a link.

While on this topic, can we talk about `adduser` and `useradd` next?

0
0
0

@bandie @monsieuricon I use the -s to remind me it's ln -s source destination

0
0
0

@monsieuricon It's
ln -s $(pwd)/target path/to/linkname

0
0
0

@monsieuricon "it's the same as cp" doesn't work for me either. My mnemonic: The name of the real file is required. It goes first. The name of the new symlink is optional (if you don't provide a name it uses the real file's basename). It goes second.

1
0
0

@monsieuricon Especially fun when symlinking directories, where you can end up creating a new link within the directory if the intended symlink already exists

0
0
0

@monsieuricon Same. 25 years and still cannot figure it out.

0
0
0
@monsieuricon I just gives up and do
ln -s target
mv target linkname
0
0
0
@mw @wzyboy @monsieuricon
> Just treat it as cp.

nah ln is the other way around (is it? damn, I need to man it now).
1
0
0

@dan @monsieuricon Yeah, it's super dumb, annnnd quite problematic.

But, it def stuck in my brain, and I've never needed to worry about it since. (and I use ln maybe a couple of times a year, max).

0
0
0

@monsieuricon target linkname and if you’re at thr location you want the symlink you can leave off the linkname and it will produce a symlink in pwd that has the same name as the original file

0
0
0

@jornane @monsieuricon @drahardja Think of it like a soft `cp`, always works

0
0
0

(note to self) It's like `cp`. The first argument exists, the second one is the one you want to "create".

0
0
0

@monsieuricon My version of this is ssh port forwarding.

Nowadays VScode mostly does it for me, because the alternative is to copy random strings of the internet like goddamned spells.

0
0
0
@shrik3 @wzyboy @monsieuricon Nope it's the same order. Just write a cp command and s/cp/ln -s.
0
0
0

@monsieuricon I have the same problem with grep.

1
0
0

@monsieuricon the only rule that has ever worked for me is "pretend it's the cp command" but I can't reasonably explain it in a way that couldn't be misinterpreted

0
0
0

@monsieuricon The way I remember is that it's the same order as mv and cp. Rather than <target> <linkname> think of it as <origin> <destination>

0
0
0

@monsieuricon I have a helpful mental trick to help me remember: "man ln" every single time.

0
0
0

@linuxfiend @monsieuricon grep is worse for me since I usually pipe stuff into it rather than use it directly on files.

0
0
0

@drahardja @monsieuricon Nah. No way. The only way rsync is ever used is on whole directories, `-av`, and trailing slashes on both paths. Anything else has a lower chance of success than the lottery.
(that said, I use rsync for whole directories on a daily basis)

0
0
0

@monsieuricon Always a good time to man it.

0
0
0

@monsieuricon Hahaha, so many people comparing it to any number of other commands I have to look up everytime! But I've finally learned to remember ln -s as filename then linkname bc the file must already exist -- start where you are, USE WHAT YOU HAVE, [then] do what you can! 😹

0
0
0

@monsieuricon Used to be me until I drilled it into my head that its about SOURCE and DESTINATION. "Where do we come from? Where are we going?"

0
0
0

@munin @monsieuricon @GrumpusNation Yeah, same here. The link name is optional. And if you pass only one argument, the target is the only one that makes sense. So it must come first.

1
0
0

@monsieuricon if it serves you consolation is a feeling I empathize with. Everyone who says "duh, is like mv" doesn't understand the pain and grief this tool brings to me.

0
0
0

@monsieuricon me too! 25 years using linux and check ln man every time

0
0
0

@monsieuricon @randomgeek I had the same problem for years... Then it clicked. It is the same as `cp`

So, if I ever forget I write the command as if I was copying the file, and then change `cp` to `ln -s`

0
0
0

@monsieuricon Destination (the "created" file, or the directory it/they goes/go in) is always last for cp, mv, and ln.

0
0
0

@Steveg58 @monsieuricon yes... yes... wait, except when you think of ln as a file alias, and alias is the other way around...

1
0
0

@monsieuricon Same. And back when I learned Unix in 1993 the man page/help said “ln source target” which, I mean, even that was confusing to me.

0
0
0

@clusterfcku @monsieuricon
ln existing_file new_alias

not seeing an exception. :)

1
0
0

@raggi @monsieuricon yeah... but not alias; troublesome for those who feel ln is more like alias than cp, right?

1
0
0

@clusterfcku @monsieuricon it's this thinking which leads to the manpage being super confusing.

$tool $existing_path $newly_created_path

forget the minutae, start with the simpler description!

1
0
0

@clusterfcku @monsieuricon
alias is not a proper *nix command it is a shell thing.

1
0
0

@Steveg58 @monsieuricon yeah i'm not arguing the pattern you stated, i'm just reflecting on the mental model which is how some of us end up sweating with hovering finger

1
0
0

@clusterfcku @monsieuricon
Sure but that is the mental model I have been successfully using since the 1980s to avoid the man lookup.

0
0
0

@monsieuricon i'm kind of fascinated that people think it worthwhile to try to school *you* of all people, if even @monsieuricon has trouble with this, the problem is not with @monsieuricon, it's with the damn thing :)

0
0
0

@monsieuricon "I'm in this picture and I don't like it."

0
0
0

@monsieuricon

we all have some unix/linux command we have a mental block and have to check the man page every time. one of mine is "zip".

1
0
0

@monsieuricon Think of it like copy. It's the same order as cp

0
0
0

@monsieuricon @inthehands This is going on the Post-it on my display, below the root pw 😛

0
0
0

@monsieuricon

Just remember that ln has a single operand option and you'll never need to look at the documentation again.

0
0
0

@monsieuricon I think of it like cp/mv because the order is "existing thing" "new thing"

1
0
0

@monsieuricon I understand it, I know all of the tricks to remember, but I never get it right. I now just never do this as root and never without trying it once on another system just to be sure. This is clearly just beyond human intelligence.

0
0
0
@encthenet @monsieuricon yeah but mentally I often think of the link going the opposite direction: I want it to go FROM the link TO the real file
1
0
0

@monsieuricon @dgar every single time - my command history is:

$ man ln

$ ln -s blah blah

Cannot make it stick.

0
0
0

@monsieuricon I tend to remember because you can omit the second parameter (the link name is optional in this case)
ln -s /some/other/directory
and create a link to that directory in the current directory with the same name. So, the 2nd one is what you want to call it.

1
0
0

@monsieuricon But yeah, is it
zip *.txt txt.zip
or
zip txt.zip *.txt
is the one that gets me.

0
0
0
@encthenet @monsieuricon and then I just use the install command instead because it does relative symlinks that will still work when accessed from outside the jail/chroot, but I can't explain why I don't confuse the ordering here.

Now that you have me thinking deeply about this I propose this theory: ln is a tool you learn early on in your *nix journey, but many people are confused by it initially like why it doesn't stay in sync if you rename or move the file. You may have lost data from doing the order wrong, so there's a bit of confusion/trauma burned into your memory. Using it always brings that feeling of uncertainty back.

But another tool that you learned much later and has identical functionality? No uncertainty
0
0
0

@mezzodrinker @monsieuricon one thing that helped me is knowing that ln -s is the same order as cp or mv

0
0
0

@monsieuricon I blame Microsoft, for doing everything in the opposite order Unix did.

0
0
0

@paul_ipv6 @monsieuricon haha I was going to respond `ln -s` but I see the OP which started the thread and guess I'm in good company 😁

0
0
0

@monsieuricon it's easy to remember: you *need* the target, but a link name is optional, can be derived from the target you provide. So the target is first, and only if you need to change from default do you provide a link name.

0
0
0

@monsieuricon What I do:

1. ln -s something otherthing
2. If I didn't get an error, all good. Stop.
3. If I got an error, check if it's trying to clobber the source.
4. run ln -sf with the right args this time.

0
0
0

@monsieuricon
As a former gentoo user who compiled his own kernel I don't struggle with ln -s anymore. But there are other examples where I struggle. I totally get that one. 😅
@Madic

0
0
0

@rhoot @munin @monsieuricon @GrumpusNation 'only one that makes sense'

tell me you speak a nominative (rather than ergative) language without telling me :p

0
0
0

@monsieuricon easy to remember the order if you can remember linkname is optional

0
0
0

@monsieuricon documentation keeps on becoming more and more readible as you keep on being more and more experienced :)

0
0
0

@monsieuricon thank you! I was thinking is only my problem after admining 20+ years ;) @rysiek

1
0
0

@monsieuricon I feel like we could afford to make a better convention for these tools. Like using > to indicate directionality (I know that's used for redirection, though) or... something. What sort of hints could make these tools easier to use?

1
0
0

@monsieuricon@social.kernel.org If only one could pass the two things as explicitly named parameters like --path and --target, maybe even with tab completion for those parameter names

0
0
0

@monsieuricon haha while i'm in the "bro it's like cp(1)" crowd, i can appreciate where you're coming from because of memcpy(dest,src, ..).

i tend to find myself in this situation when it comes to unfamiliar assembly syntaxes, or even at&t vs. intel -- is it like cp(1) or is it like memcpy(3)

0
0
1

@monsieuricon lesson i had to learn the hard way: don't guess wrong when you're root and saying -f -s

fortunately i had a spare copy of busybox on hand...

0
0
0

@monsieuricon

30 but same … until someone said “it's the same way 'round as cp”

0
0
0

@monsieuricon I have the same problem until I realized, that I don't need enter linkname there. Only when I need change the name. So it Is always "ln -s source" and it will create link to source file in current directory.

0
0
0

@monsieuricon Same here. I just learnt the order oft the words by heart: target linkname - target linkname - target linkname - so I can skip looking into the manpage, but I still actively have to think about what it actually means.

0
0
0

@monsieuricon my mental model for all commands is that the first file is input, second is output. That said i have always had problems memorizing linux command names and arguments and need to look most of them up…

0
0
0
@monsieuricon Note that you can create multiple links to a same destination folder, with one command: `ln /foo /bar /dest`. This create two links `/dest/foo` and `/dest/bar`. Also, you can create a link with only one argument, to the current directory. With this in mind, you can not forget the order. The dest is optional, while the src can not be.
1
0
0

@bandie @monsieuricon from the link to the target or from the target to the link? 😁

1
0
0

@kaito02 @monsieuricon from the link to the past,

from source to symlink

0
0
0

@monsieuricon Luckily, you can’t do any damage by using the “wrong direction”, unless you add the -f option.

0
0
0

@piotrsikora @monsieuricon @rysiek The thing that made me remember – if you replace ‘ln -s’ with ‘cp’ it should do almost what you want. :>

0
0
0

@monsieuricon damn I feel like NOW I will start feeling that doubt after never feeling it before 🙈

1
0
0

@wzyboy@dabr.ca @monsieuricon@social.kernel.org I always press both. Precisely one of them will succeed. 😆

1
0
0

@monsieuricon I do the same thing with: "tar -czvf tarball path" and "tar -czvf path tarball".

1
0
0

@monsieuricon Here is my trick: even though we all know the '-s' is for "symbolic", let's pretend it is for "source". No need to thank me! 😁

0
0
0

@monsieuricon You have made me feel less alone this day.

0
0
0

Colin Rosenthal ❤️🇮🇱❤️

Edited 1 month ago

@monsieuricon Every f*cking time.

0
0
0

@slothrop @monsieuricon after many years I finally managed the ln -s syntax, but I cannot for the life of me remember if it is "chown -R" or "chown -r".

0
0
0

@monsieuricon @pluralistic It's like mv and cp: first the file that already exists, then the one you want to create.

0
0
0

@monsieuricon agree, it's like a 'rm -rf' you always need to think twice before clicking return.

0
0
0

@monsieuricon I try to remember this by assuming that the second argument is the one that's optional

0
0
0

@monsieuricon I have always felt it was backwards. And then to make it worse, I get used to ln and meanwhile the Windows mklink does it the other way around, so my confusion is only compounded going back and forth.

0
0
0

@tauon @monsieuricon what if they're in the same directory?

1
0
0

@monsieuricon powershell uses explicit `-Path -Target` args and I still manage to mix them up

0
0
0

@monsieuricon I actually remembered this 20 years ago because I gave the -s the alternative meaning of "source". So if you think it like this, you'll never be wrong

0
0
0

@rail_ @monsieuricon easy trick to remember, it's like cp!

0
0
0

@monsieuricon in all those cases - mv, cp, ln etc. - it is always old → new - old on the left, new of the right, so that the old precedes the new. This order is natural to people writing left-to-right, probably less natural to Arabs, Jews and other people whose language is written right-to-left…

0
0
0

@monsieuricon the way I remember is that `ln -s targetname` works (links to a matching named link in the current directory. Therefore the targetname has to come first.

0
0
0

It is the same as cp. So src trgt. Not sure why it is so hard to remember.

One copies file to somewhere or links one file to somewhere.

0
0
0

@monsieuricon feel your pain

0
0
0

@monsieuricon
it's interesting that this is such a universal human experience. IMO, this is the kind of thing that we would like AI to help with such that we don't have to open the man page for the 1000th time.

0
0
0

@monsieuricon The last parameter is optional, and if you think about it that way, only one variation makes sense.

0
0
1

Steve Hill 🏴󠁧󠁢󠁷󠁬󠁳󠁿🇪🇺

@monsieuricon it is exactly the same order as cp and mv

0
0
0

@monsieuricon "-s" is followed by SOURCE. This is how I managed to remember it.

0
0
0

@monsieuricon Yeah.... well... one of the target/linkname makes sense without the other. (Because the other one can be deduced.) Which one?

0
0
0

@monsieuricon Hehe, I think it's one of the very few things where I say "ln -s target linkname" (from the manpage?) in my head every time because I also had this problem for a while. IIRC I put it on a post it and read it to myself dozens of times... in the 90s.

0
0
0

@monsieuricon @da_667 Same timeline but the only way I remember is because you can leave off the second argument and it creates the symlink in the present working directory with the same name as the target (which I've done in the last week).

0
0
0

@pronounshe @monsieuricon
Think “tar -czv -f=tarball path“

1
0
0

@monsieuricon 100% this. See also… howthefuckdoitar dot com https://howthefuckdoitar.com

0
0
0

@monsieuricon I've been in the scene since the early 2000s and I still have to look it up, or try the wrong side first.

0
0
0

@monsieuricon I think of it in terms of "which precious file gets clobbered?".

cp A B : hope you didn't want anything from B
mv A B : bye-bye B
ln -s A B : all B's hopes and dreams are replaced with a link to A

I know that ln by default won't clobber B, but I don't trust that behaviour.

0
0
0

@cathos @monsieuricon there’s thousands of things wrong with the unix tools and command line. we could have a much better command shell if the existing one weren’t *juuuust* good enough to not be worth changing it

0
0
0

@monsieuricon The way I remember it: They're positional parameters, and you can just use "target"... so "linkname" is optional. You can't have your first positional parameter be optional. "target" goes first.

0
0
0

@corsac @monsieuricon I think you just have changed my professional life as a Sysadmin and now as a Site Reliability Engineer. Thanks for the tip!

0
0
0

I have grokked by now that the order is the same as cp, but what still trips me up is that THE SOURCE PATH IS RELATIVE TO THE DESTINATION PATH!

ln -s subdir/foo subdir/bar
cat subdir/bar

will create a symlink at subdir/bar that links to subdir/subdir/foo 🙃

@monsieuricon

0
0
0

@corsac @monsieuricon I actually prefer to do

```ln -s target``` without the linkname and then rename the targetname to the linkname, if at all necessary...

0
0
0

@monsieuricon i literally just memorised "TARGET LINK_NAME" from ln --help

0
0
0

@monsieuricon it’s semantically backwards. You want to create a link to something but actually it creates a link from something to another thing that doesn’t exist yet.

See also the X server that runs on the client machine to display windows for X clients that run on the server machine.

0
0
0

@monsieuricon @drahardja it’s just like a copy, the target goes at the end.

0
0
0

@monsieuricon
Knowing that you can omit linkname helps

0
0
0

@monsieuricon Think of it as just like cp or mv.

0
0
0

@monsieuricon I made the association "Its like cp" early on.

0
0
0

@monsieuricon Easy way to remember: It’s the same as if you were copying the file with cp.

0
0
0

@monsieuricon Yes, it's a Sapir-Whorf thing. Some languages are verb-subject-object, and some are verb-object-subject. Yoda even speaks object-subject-verb (in the original, anyway; it's trickier in the German translation).

Don't think of it as a matter of abstract intuition, but as a matter of foreign language intuition. The intuition of consistency, not the intuition of essence.

1
0
0

@monsieuricon In CP/M, copying used to go the other way: pip destination=source. If Unix has been modelled after that, we'd be doing hard links by pip destination<=souce, and symlinks as pip destination<-source.

1
0
0

@gparker But that's not cp's argument order, either. It has a ton of optional arguments that go in the middle:

cp first-file [second-file [third-file [fourth-file [...]]]] destination
@monsieuricon

0
0
0

@monsieuricon I never remember if I'm supposed to use useradd or adduser...

0
0
0

@monsieuricon I used to struggle too, now I think of it like "cp", arguments are src and new-dest

0
0
0

@monsieuricon the arrow points left to right. Link ---> Target.

Wait, is that right? I have to double check... Umm now I'm unsure...

$ man ln

What? I could of swore it was left to right. Have I been doing it wrong all this time? That can't be right. *Takes out laptop*

*battery is dead* ffs

Muscle memory types `ln -s target link`

Oh dang, it is target <-- link

0
0
0

@monsieuricon I see all those people saying "it's the same as cp". Let's make this a bit more confusing 😈...

Did you know that "cp -s SRC DST" is the same as "ln -s SRC DST"?

0
0
0

@monsieuricon Just remember it works just like "copy" :)

0
0
0

@monsieuricon “something that exists first” is the line my CS teacher spoke that stayed in my head for 30 years.

0
0
0

@monsieuricon
I am in this post and I don't like it.

At least I managed to finally memorize the most common tar parameters (fCc and x) zabout 15 years ago...

0
0
0

Mia ‘Meetings? I Abstain’ Luna Tearmoon

@monsieuricon I would totally understand this if you came from CP/M

0
0
0

Mia ‘Meetings? I Abstain’ Luna Tearmoon

@riley @monsieuricon oh I missed this comment and posted mine… (CP/M was my ‘first’ OS)

1
0
0

@monsieuricon so do I 😁😉🤣🤣🥰

0
0
0

@denix @monsieuricon @bagder

USB always needs three attempts:

1. Wait, this feels awkward, better try the other way round.
2. No, that's _definitely_ wrong. It _has_ to be the other way round.
3. Ahh...

0
0
0

@mia FWIW, I kind of suspect that CP/M's PIP was, in turn, modelled after something that DEC used to ship with PDP-11, the cradle of OSes. Even Unix comes from it!
@monsieuricon

0
0
0

@monsieuricon @kkarhan

This!

The source is an actual file I want to link to whereas the link name is a figment of my imagination I summon elsewhere to open a portal that takes me to the source which also makes the source the destination. (Shit, did I just RP a linux command? Defo need to go touch some grass. 😉)

That's why I keep confusing myself with the terms source and destination.

Maybe origin, portal name will work better? I'll give it a shot.

0
0
0

@monsieuricon my muscle memory knows it just fine but my brain has a hard time figuring out which one is correct

0
0
0

@monsieuricon second file name can be omitted, so first must be the target that's how I remember.

0
0
0

@bandie
That's exactly my thinking!

A link is something that points *from* the link *to* a real target (as implied by the arrow used to display them in 'ls - l').

But to create a link I have to use 'ln -s $to $from'.

For my brain this is simply wrong…

@monsieuricon

0
0
0

@monsieuricon I seem to do it correctly only if I don't think about it. Otherwise, I couldn't possibly tell you without looking it up!

0
0
0

@monsieuricon My memoisation: It works like mv.

2
0
0

@monsieuricon it me. i always man ln before i use it

0
0
0

@monsieuricon easy way (for me) to remember it: the last argument is optional. If you do not provide a linkname then the link will be created in the current directory with the filename of the target. So the order must be "target linkname".

0
0
0

@monsieuricon I'd also say it's the EXACT DIAMETRAL OPPOSITE of cp.

"copy this to that"
versus
"create link 'that' pointing to 'this'"

you literally create something at location 'that', which is mentioned in different order.

1
0
0

@williampietri
At least it always does the same thing, vs. cp where it matters if dest already exists...
@monsieuricon

0
0
0

@monsieuricon every time i check it ends up being the other way around anyway so i’ve stopped checking and just use -v 🦋

0
0
0

@monsieuricon

I've been on Linux less than a year, but make a lot of hard links. Not symbolic links, but hard links. I think they're cool so I look for opportunities to use them.

Anyway, for hard links it is:
ln existing_hardlink new_hardlink

Basically, first listing what I have, then listing result output.

So, following that logic...
ln -s target linkname

I think "target" is a confusing label for the source file. I prefer to think of it as existing_path and new_link instead.

0
0
0

@monsieuricon It won’t help, but in the olden days (at least), mv, cp & ln were all links to the same binary, which examined its argv[0] to see how it was invoked. That was such a weird hack that it’s been easy (for me) to remember all these decades later.

0
0
0

@monsieuricon cp, mv, ln are one family - just think cp source destination: first you state the existing file, then you state the name where you would like to see it. you don't want to actually copy? replace cp by ln -s. @markusr

0
0
0

@ushuz @akira @monsieuricon no it means “symlink”. Without -s, ln creates a hard link

1
0
0

@monsieuricon instead of properly typing the arguments, I end up installing& running midnight commander. That is happening since 1998 :-)
It must have a story.

0
0
0

@monsieuricon
Univese brain: add a ln --symlink-to= option. 😁

0
0
0

@tjk @monsieuricon that's a good way to remember because I think the confusion is that a symlink itself points to a target thing so is the source the symlink itself that points or is thw source the real file and the target the symlink you want to create?

0
0
0

@monsieuricon ok, I mostly tldr the syntax for most Linux commands, but this one I know. For some reason it sticks. My trick is the 2nd argument is optional, if omitted, the link in the current directory is the file name linked to (without the path). I use this all the time and thus when I want to give it a different name, I simply add that name as the 2nd argument

0
0
0

@monsieuricon it is easier to swear when the error message pops up, instead of checking before giving the command

0
0
0

@kkarhan @monsieuricon “Obviously” doesn’t exist in human-made conventions like this.

`alias` takes the new name first, as does `bind`, `declare`, etc. just among bash builtins. Many commands in eg Perl take the destination first because some accept a list of sources and historical convention is to make the listable argument last.

Whether a convention is “obvious” is a matter of individual perspective. The word doesn’t belong in respectful technical discussion.

1
0
0

@kkarhan @monsieuricon $source and $destination of the linking operation, not $source and $destination of the resulting link.

1
0
0

@matt @monsieuricon from/to order does make sense almost always.

There are solutions to the list issue:

0
0
0
@monsieuricon I work on the principle that `ln /some/thing` creates a link called `file` in the current directory to `/some/thing`. So the first argument must be the thing that already exists as sometimes it's the only argument.
0
0
1

@monsieuricon that's why i like the phthon feature:
ln(target='parrot',linkname='fjord')

0
0
0

@monsieuricon

FWIW, ln doesn't seem at all like cp to me. *nix commands be like:

tool thing where-thing-goes

That's how mv and cp work. With ln the "thing" is the link, which points to the target (where thing goes).

I'm just glad that getting ln the wrong way around isn't destructive.

0
0
0

@monsieuricon for all commands, like mv, cp, ln, it's always "cmd old new".

0
0
0

@wzyboy @akira @monsieuricon mistaking it as "source" worked for me though, lol

0
0
0

@monsieuricon

I'm in this photo and I don't like it. XD

0
0
0

𝚂𝙸𝙼𝙾𝙽𝙿𝚄𝙽𝙺 𝟸𝟶𝟽𝟽

@monsieuricon @Jake this is easier to remember if you associate the -s parameter with the word “source” which goes first (source starts with s) well that’s how I remember anyway

1
0
0

@dalboz @monsieuricon I’m going to finally stop looking it up because of this. 😄

1
0
0

@stacyharper @monsieuricon
same here, the one thing there can only be one of is the thing linked to, so it must be the first. Everything following must be linked to that.

(just dont think about how copy works...😬)

0
0
0
@monsieuricon
Even if I check the man page, I still get confused. Its trial and error every time.
0
0
0
@monsieuricon I memorized "path to file, path to symlink" for this issue. I don't know why, but that was memorable for me.
0
0
0

@monsieuricon I remember it as "it's the same order as cp"

0
0
1

@monsieuricon
You can memorize it as "Elon Starlink":
ln -s target link
(E)l(o)n -s tar(get) link
Elon -starlink

0
0
0

@monsieuricon Think of cp, just not copy, but create link instead.

0
0
0

@monsieuricon I fully identify but at least the “failure mode” tends to not be destructive!

0
0
0

𝚂𝙸𝙼𝙾𝙽𝙿𝚄𝙽𝙺 𝟸𝟶𝟽𝟽

@Jake @monsieuricon gladi could help. mentally for me symlinks have always been “pulling source into current directory” rather than pointing at a target

0
0
0

@monsieuricon That’s a relief; I had just assumed my brain was broken.

0
0
0
@monsieuricon @cakeisnotalie What keeps it straight in my mind is remembering that it can take only one argument. As long as I can remember *that*, it all makes sense!
0
0
0

@monsieuricon I'll see your 25 years and raise you 38. Only obviously not linux but UNIXs

0
0
0

@monsieuricon Solution: remember that the argument order is the same as with cp 😀

0
0
0

@monsieuricon I remember it using the following approach: if you give it a single argument, then it creates that file name in CWD. Therefore, the second argument must be the name of the target.

0
0
0

@monsieuricon it was on my whiteboard for some time. I had to memorize that explicitly. I am thinking writing a song maybe.

0
0
0

@monsieuricon And that’s nothing comparing zip(1). EVERY BLOODY TIME I have to find out that it is zip -d archive filemask!

0
0
0
Back in the 1990s my supervisor said something similar to me, and my response was "it's the same way round as with mv - existing name first, new name second" and I think he had some kind of religious moment ;)
0
0
0

@dj3ei @hennichodernich @monsieuricon

Yeah `mv` is kind of the Star Trek teleporter, and `ln` one of those episodes where you wind up with two of someone.

0
0
0

@jupiter @monsieuricon

No?

cp: Create a copy of $1/$source at location $2/$destination

ln: Create a link to $1/$source at location $2/$destination

mv: Move $1/$source to $2/$destination

The order of arguments are always source first, then destination.

1
0
0

@schmittlauch @monsieuricon Also always seen it as "it's like copying a file (except the result is not an actual copy)", but the ln help makes it harder to think like that by designating the original file in the first parameter as TARGET.

0
0
0

@monsieuricon I feel you. I have the same issue for the same amount of time.

0
0
0

@monsieuricon
I just remember that it's the opposite of the one I think it should be at first.

0
0
0

@monsieuricon
I remember "-s" as source (even if it actually means "symbolic"), so that's "ln -s source newshorcut". "source" like "the original file".

0
0
0

@monsieuricon
Always source -> destination.
|
Source of the link.

Left button. 🙃

0
0
0

@jrose @monsieuricon @uliwitness this trick never worked for my brain , because most of the links I create are relative and then cp wouldn’t work unless you happen to be in the same directory. I don’t think I ever would have learned the order by heart if I hadn’t dealt with so many symlink related compiler issues

1
0
0

@jrose @monsieuricon @uliwitness the only way I remember is that you can omit the link name, so of course it comes second.

0
0
0

@bdwl @monsieuricon @uliwitness I just don’t create links not in the directory, I want tab-completion for the source anyway.

0
0
0

@corbet @monsieuricon "rename that doesn't remove the old file" is just a complicated way to say "cp", right?

0
0
0

@monsieuricon @monsieuricon how about this trick: it’s “target linkname” because linkname can be omitted for the link to get the same file name and that wouldn’t work the other way around.

0
0
0

@monsieuricon Do not check, just try. The incorrect one is harmless, it just file because there is already a file where you want to put the link.

0
0
0

@syklemil @monsieuricon huh...

I literally read the manpage...

Must have misread then. I guess that proves the point how confusing it really is.

1
0
0

@jupiter

My impression is more that I'd never actually think it was confusing if it wasn't for the posts telling me it's confusing. The confusing-ness of ln seems like entirely an informed attribute.

That is: ln isn't confusing in itself, but the people who claim it is, they're making it confusing. Because when you use ln, you're reminded of them, and then you get confused.

@monsieuricon

0
0
0

@monsieuricon 15 years for me, same.

My worst enemy is the fact that on Windows, the cmd MKLINK command has the reverse order. And the Powershell alternative command is so verbose it's annoying.

0
0
0

@monsieuricon I don't claim to have actually remembered the correct order -- instead, my fingers habitually type
`ln -s that-thing-over-there .` and if I need it to be something different, the idiom makes it easy for me to see which I need to change.

0
0
0

@monsieuricon

I have never had this problem. Until just now.

Thanks. Thanks a lot.

0
0
0

@monsieuricon
Until I read this post I'd just finally got it clear in my head.

0
0
0