There’s 2 types: soft links and hard links.
What they are:
Soft links tell the system to open the target of the link, ie the thing for which you’re creating a link. It’s just a reference to the original file. It’s a bit like how an alias operates in a GUI, and points the system to the right location to use the original.
Hard links point directly to a physical piece of data, to the file itself. (Whereas the soft link is a reference to the name of the file, the hard link is another name for the data itself.) Methinks that by the time you’ll be needing to make hard links you’ll probably know what, why, and how. So I’ll just talk about soft sym links.
The syntax is:
ln -s [file] [symlink_name], where both quantities are file names or full paths plus file name.
Making a file and a link to it:
1 2 3 4 5 6 7 8 9 10
Afterwards, anything called on that link will act as if called on the original, as if the link didn’t even exist
1 2 3 4 5 6 7
Removing the sym link:
Done the same as for any other file. And rest assured, removing the symbolic link doesn’t remove the target of that link.
1 2 3
As far as I know the name of the link doesn’t matter at all, but it’s a good idea to name it similarly to or with the same extension as the original, so future devs know how to call the file.
The soft symbolic link, unlike Mac OSX GUI aliases, doesn’t follow the target file if it’s moved.
Let’s start over. Make the file and sym link:
1 2 3 4
Move the target:
Yup, it’s there:
1 2 3 4
But try to execute the sym link, and the system doesn’t know what’s being referenced:
Righto. Over and out.