Linux and Unix link command

Quick links

About link
Syntax
Examples
Related commands
Linux and Unix main page

About link

Calls the link function to create a link to a file.

Syntax

link FILE1 FILE2
link OPTION

Description

The link command creates a hard link named FILE2 which shares the same index node as the existing file FILE1. Since FILE1 and FILE2 share the same index node, they will point to the same data on the disk, and modifying one will be functionally the same as modifying the other.

This is distinct from creating a "soft" symbolic link to a file, which creates its own index node and therefore does not directly point to the same data.

For example, a user cannot create a hard link which links to a directory; but this can be accomplished using a symbolic link.

Options

--help display help and exit.
--version display version information, and exit.

Examples

link computer.txt hope.txt

The above example would create the file hope.txt linked to the file computer.txt. Any changes that occurred with either of these files would affect the other file or link.

Related commands

ln — Create a link, or a symbolic link, to a file or directory.
ls — List the contents of a directory or directories.
unlink — Remove a file.