About
A soft link, symlink or a symbolic link is a file that redirects (link) to another file.
It's the alias functionality of a file system.
Unlike a hard link, a symbolic link can link to any file on any computer.
Operating System
Linux
Creation
They are created with the ln command.
They are created with the ln command and the -s parameter:
ln -s /the/full-real/file/path /the/sym/link/file/path
ln -s /the/full-real-path/to-directory /the/symlink/directory/path
ln -s /etc/dbora /etc/rc.d/rc2.d/S99dbora
See canonical/real path:
readlink -f /the/sym/link/file/path
Remove Without trailing slash:
- unlink
unlink /the/sym/link
- or remove
# rm /the/sym/link/ <- Bad
rm /the/sym/link
Target
Target of symlink can be:
- a path to:
- a regular file
- a pipe (pipe:[2333507])
Windows
Symlink are also known as junction on Windows.
Dos
Windows shortcut are not symbolic link
mklink
Creates a symbolic link.
MKLINK [[/D] | [/H] | [/J]] Link Target
/D Creates a directory symbolic link. Default is a file
symbolic link.
/H Creates a hard link instead of a symbolic link. (Works only with files ? See option /D)
/J Creates a Directory Junction.
Link specifies the new symbolic link name.
Target specifies the path (relative or absolute) that the new link
refers to.
Example for:
- a file
mklink targetSymlink sourceFile
REM with a php ini file
mklink C:\php-7.2.6-Win32-VC15-x64\php.ini D:\repo_backup\php.ini
symbolic link created for C:\php-7.2.6-Win32-VC15-x64\php.ini <<===>> D:\repo_backup\php.ini
- A directory
mklink /D symlink directory
REM example for the preferences directory of Eclipse
mklink /D "D:\workspace\.metadata\.plugins\org.eclipse.core.runtime" "D:\svn\Config\Eclipseorg.eclipse.core.runtime"
symbolic link created for D:\workspace\.metadata\.plugins\org.eclipse.core.runtime <<===>> D:\svn\Config\Eclipse\org.eclipse.core.runtime
- List: the dir command show the target of symbolic links (called Reparse Points)
dir /a:l
/A Displays files with specified attributes.
attributes D Directories R Read-only files
H Hidden files A Files ready for archiving
S System files I Not content indexed files
L Reparse Points - Prefix meaning not
Powershell
- GetFinalPathNameByHandleA function - Retrieves the final path for the specified file.
Security and Developer Mode
On Windows, you can activate Developer Mode to allow non-admin users to create symlinks by following this instructions.