in
Test if value is in set
TLDR
View documentation for the for keyword
SYNOPSIS
ln [OPTION]... TARGET... DIRECTORY
ln [OPTION]... TARGET
ln [OPTION]... TARGET... TARGET
PARAMETERS
-s, --symbolic
Make symbolic links instead of hard links.
-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.
-v, --verbose
Print the name of each linked file.
-b, --backup[=CONTROL]
Make a backup of each existing destination file.
-S, --suffix=SUFFIX
Override the usual backup suffix.
-V, --version-control=WORD
Override the default version control behavior.
-t, --target-directory=DIRECTORY
Specify DIRECTORY in which to create the links.
--help
Display a help message and exit.
--version
Output version information and exit.
TARGET
File/directory to be linked.
DIRECTORY
Directory to create the link in.
DESCRIPTION
The ln command in Linux is used to create links between files. These links can be either hard links or symbolic (soft) links. A hard link creates a new directory entry that points to the same underlying inode as the original file. This means that both files essentially share the same data. A symbolic link, on the other hand, creates a new file that contains a pointer to the original file. It acts as a shortcut. Changes to the original file are reflected in both the original and the symbolic link. If the original file is deleted, the symbolic link becomes a dangling link, pointing to a non-existent file. The 'ln' command is crucial for organizing files, sharing data between directories, and creating aliases for commonly used files. It is especially useful for managing configuration files and libraries.
When creating symbolic links, the -s option is essential, otherwise hard links are created. The user needs to have write permission in the directory where the link is being created.
CAVEATS
Deleting the original file will make symbolic links dangling. Hard links do not have this problem, but changes to one hard linked file are visible in all hard linked files because they all point to the same inode. When creating hard links across different file systems is not possible.
EXIT STATUS
0 for success, 1 or greater for failure.
HISTORY
The ln command has been a part of Unix since its early days, appearing in Version 1 Unix in 1971. Its purpose was to provide a mechanism for creating aliases for files and directories, improving file system organization and simplifying access to commonly used resources. The concept of hard links was fundamental to Unix's file system structure, while symbolic links were added later to provide more flexibility and overcome limitations of hard links (such as the inability to link across file systems). Over the years, ln has seen various enhancements, including options for creating backups, interactive prompts, and controlling versioning. It remains a core utility in modern Linux and Unix-like systems.