In computing, a symbolic link (also symlink or soft link) is a term for any file that contains a reference to another file or directory in the form of an absolute or relative path and that affects pathname resolution. Symbolic links were already present by 1978 in minicomputer operating systems from DEC and Data General's RDOS.Today they are supported by the POSIX operating system standard. What Are Symbolic Links? Symbolic links are basically advanced shortcuts. Create a symbolic link to an individual file or folder, and that link will appear to be the same as the file or folder to Windows—even though it’s just a link pointing at the file or folder. The Best Tech Newsletter Anywhere.
What are they?
Symbolic links are like shortcuts or references to the actual file or directory. Most of the time these links are transparent when working with them through other programs. For example you could have a link to a directory to one hard drive inside a directory that lies on a different hard drive and an application will still treat it the same.
Symbolic links are used all the time to link libraries and make sure files are in consistent places without moving or copying the original. Links are often used to “store” multiple copies of the same file in different places but still reference to one file.
Creating a Symbolic Link
To create a symbolic link in Linux we use this syntax:
What happens if I edit the link? Any modifications to the linked file will be changed on the original file.What happens if I delete the link? If you delete the link the original file is unchanged. It will still exist.What happens if I delete the original file but not the link? The link will remain but will point to a file that does not exist. This is called an orphaned or dangling link.
Creating a Hard Link
You can create a hard link like so:
The Difference Between Soft and Hard Links
Hard links
Symlinker
- Only link to a file not a directory
- Can not reference a file on a different disk/volume
- Links will reference a file even if it is moved
- Links reference inode/physical locations on the disk
Symbolic (soft) links
- Can link to directories
- Can reference a file/folder on a different hard disk/volume
- Links remain if the original file is deleted
- Links will NOT reference the file anymore if it is moved
- Links reference abstract filenames/directories and NOT physical locations. They are given their own inode
Practice Makes Perfect
To really grasp the concept of symbolic links lets give it a shot.
Go into the tmp directory:
Make a directory
Copy over the host.conf file or any file to test with.
List the contents and take note of the inode (first column)
Create a symbolic link to host.conf called linkhost.conf
Now do list out the inodes
Notice how the inode for the link is different.
Now create a hard link to the same file
Now list the inoes one more time
Notice how the inode numbers are exactly the same for the hard link and the actual file.
Lets try some file operations now
Open up linkhost.conf and edit it and save it
Now look in host.conf and notice that the changes were made
Lets move host.conf now and see if it causes any problems
Uh oh, now when we list the directory our link turned red lets see what is in side it
It looks like our symbolic link is now broken as it linked to a file name and not the inode. What about our hard link?
Looks like our hard link still works even though we moved the original file. This is because the hard link was linked to the inode the physical reference on the hard drive where the file resides. The soft link (symbolic link) on the other hand was linked to the abstract file name and was broken the moment we moved the file.
This leads to an interesting question. What happens if I delete a hard link? Even though the hard link is referenced to the physical location of the file on the hard drive though an inode, removing a hard link will not delete the original file.
Symbolic links will remain intact but will point to a non existent file.
A free and open source contextual menu plugin for Mac OS X that allows users to make symbolic links in the FinderAs some of you may have noticed, a number of Unix tools, especially file and Web servers (such as FTP, NFS, Samba, and Apache), have trouble resolving the System 7 style alias files created by the Finder's 'Make Alias' command.
Symbolic Linker Download
Many of these tools think these alias files are actually regular files with nothing inside them, which makes them useless in some situations. Just about all Unix tools, however, can resolve symbolic links.Symbolic Linker Mac Download
Symbolic links are similar to aliases, except that they point back to the original file in a way that every Unix application can understand. Until now, however, creating a symbolic link usually involved a trip to the Terminal.
SymbolicLinker is a tiny contextual menu plugin that, once installed, allows any user to create symbolic links to files inside the Finder. SymbolicLinker does this by adding a contextual menu item to the Finder that generates symbolic links to the selected files.
SymbolicLinker's goal is to decrease users' trips to the Terminal in order to use the 'ln -s' command. SymbolicLinker is available in English, Finnish, Japanese, Spanish, Swedish, French, German, Italian, and Turkish.
Installation:
1. Open the folder titled 'Library' at the root of your boot disk. Make sure there is a folder there named 'Contextual Menu Items'. If the folder doesn't exist, then make one with exactly that name (without the quotes, of course). If you are not the system administrator, or you do not want the plugin to be available to all users on the system, then use the Library folder inside your home directory instead.
2. Copy the 'SymbolicLinker.plugin' folder that came with this distribution into the Contextual Menu Items folder.