After working with Linux on a day to day basis for a long, long time now, it was today that I finally clicked with the ln -s
command for making symbolic links, aka “shortcuts” in the file system. When using that command with two parameters, one of them is the source/origin of the link and the other one is the target. I’ve always struggled to remember if “source” is the actual file on disk, or the place where I want to link from (the “origin” of my jumping to the destination). What do I write first? The location where I want the shortcut to appear, or the location of the actual file?
Well, I struggle no more. (Probably. It’s very possible that I’ll forget this in a week.) It’s because when I checked the documentation (for the n-th time) today, I saw that the ln
command can take different forms depending on the number of parameters you feed it:
ln -s <file>
This will create a link to<file>
in the current working directoryln -s <file> <place>
This will create a link to <file> in the place that you specify as the second parameter
The thing that caused it to click for me was realizing that the second parameter is optional, which means that the first parameter logically must be the actual file.
It all makes sense if you stare at it for long enough. Say, 25+ years.