s6-portable-utils: the s6-ln program
Keywords: s6-portable-utils command s6-ln ln link symbolic hard

s6-portable-utils
Software
skarnet.org

# The `s6-ln` program

s6-ln creates a link to a file.

## Interface

         s6-ln [ -n ] [ -s ] [ -f ] [ -L ] [ -P ] source... target

s6-ln acts as the generic ln utility.

## Options

- `-s` : create a symbolic link instead of a hard link
- `-f` : force replacement of an existing target
- `-L` : link targets of symlinks in source...
- `-P` : link symlinks in source... themselves
- `-n` : if target is a symlink to a directory, replace it instead of adding a link in the directory

## Posixness

s6-ln would be suitable as a Single Unix ln program, except that POSIX mandates that a preexisting target must first be `unlink()`ed and then (`sym`)`link()`ed, which prevents atomic replacements. `s6-ln` aims to be reliable and allow for atomic replacements, so it deviates from POSIX on that point: when target exists and needs to be replaced, `s6-ln` first creates a (sym)link to a unique temporary name, then `rename()`s the temporary name to target. This behaviour makes sure that target is atomically replaced - there's no point in time where it does not exist.