sln
Create symbolic links
SYNOPSIS
ln -s [TARGET] [LINK_NAME]
PARAMETERS
TARGET
The file or directory to which the symbolic link will point.
LINK_NAME
The name of the symbolic link to be created. If omitted, the link will be created in the current directory with the basename of the TARGET. However, it's highly recommended to specify the name explicitly.
-b, --backup[=CONTROL]
Make a backup of each existing destination file.
-d, -F, --directory
Allow superuser to attempt hard link directories.
-f, --force
Remove existing destination files.
-i, --interactive
Prompt whether to remove existing destination files.
-n, --no-dereference
Treat destination that is a symbolic link to a directory as a normal file.
-s, --symbolic
Make symbolic links instead of hard links. This is the main option for creating symbolic links.
-S, --suffix=SUFFIX
Override the usual backup suffix.
-t, --target-directory=DIRECTORY
Specify the DIRECTORY in which to create links.
-v, --verbose
Print the name of each linked file.
--help
Display a help message and exit.
--version
Output version information and exit.
DESCRIPTION
The `ln` command in Linux, specifically with the `-s` option, creates symbolic links (also known as soft links). A symbolic link is a file that contains a text string that is interpreted as the path to another file or directory. Unlike hard links, symbolic links can point to files on different filesystems and even to directories. If the target file is moved or deleted, the symbolic link will become a broken link (dangling link) because it still points to the old location. Symbolic links are very useful for creating shortcuts to files in convenient locations, managing library versions, and organizing complex file systems. The target file's permissions and ownership do *not* affect the ability to access the target file using the symbolic link; instead, the permissions of the *linked* file (the symbolic link itself) control access. This command provides a flexible way to maintain file system organization.
CAVEATS
If the target file is moved or deleted, the symbolic link will become broken. Relative symbolic links are relative to the *location* of the link, not the current working directory when the link is used.
<B>EXAMPLES</B>
- Create a symbolic link named 'my_link' to the file 'original_file':
ln -s original_file my_link
- Create a symbolic link to a directory:
ln -s /path/to/directory my_link_to_directory
- Create a relative symbolic link: if your link will be always used from the directory where it resides, use a relative path for more robustness if the directory gets moved.
ln -s ../original_file my_link
<B>HARD LINKS VS. SYMBOLIC LINKS</B>
Hard Links:
- Share the same inode as the original file.
- Cannot link to directories (usually).
- Cannot link across different filesystems.
- Deleting the original file does not affect the hard link.
- Modifying one link modifies the data visible through all links.
Symbolic Links:
- Are separate files containing the path to the original file.
- Can link to directories.
- Can link across different filesystems.
- Deleting the original file makes the symbolic link broken.
- Modifying the original file is reflected when accessing the symbolic link.
HISTORY
The `ln` command has been a standard part of Unix-like operating systems since their early development. The `-s` option for creating symbolic links was introduced later to address the limitations of hard links, particularly their inability to cross filesystem boundaries and to link to directories. Symbolic links provide a more flexible way to manage files and directories.