Low Orbit Flux Logo 2 F

Linux Command - ln

The linux ln command creates links.

These will be either:

See our other guide for more background on Difference Between Soft and Hard Links

Note:

Create a hard link:



ln test1.txt link1.txt

Create a sym link:



ln -s test1.txt link1.txt

Create a relative link:



ln -s ../../../home/user1/test1/test1.txt link1

Create an absolute link:



ln -s /home/user1/test1/test1.txt link2

More relative and absolute links:



ln -s ../../../etc/hosts link3
ln -s /etc/hosts link4

Broken link:



ln -s doesnt_exist.txt new_link.txt
ln -s ../etc/hosts link3

Don’t need to specify path, will use the same name by default ( can’t be in the same dir ):



ln -s ../../../etc/hosts

Link to a directory:



ln -s dir1 abc

There are a lot of other options. Most of them aren’t really very common and are of limited use.