18.5 C
New York
Tuesday, April 16, 2024

symlink – Link command in terminal vs ln vs symbolic link (ln -s) differences between them?


Both commands have the same inode number, so they consist of the same code.

$ ls -il /bin/{link,ln}
1152921500312524105 -rwxr-xr-x  2 root  wheel  101968 Mar 21 07:13 /bin/link*
1152921500312524105 -rwxr-xr-x  2 root  wheel  101968 Mar 21 07:13 /bin/ln*

If you run man link, you get the same man page as for ln. The difference is that link doesn’t take any options and always creates a hard link.

SYNOPSIS
     ln [-L | -P | -s [-F]] [-f | -iw] [-hnv] source_file [target_file]
     ln [-L | -P | -s [-F]] [-f | -iw] [-hnv] source_file ... target_dir
     link source_file target_file

...

When the utility is called as link, exactly two arguments must be supplied, neither of
which may specify a directory.  No options may be supplied in this simple mode of operation,
which performs a link(2) operation using the two passed arguments.

Honestly, I don’t see a practical use for link (I didn’t even know this variant exists, and I’m using Unix-style systems for >30 years now).

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles