Skip to main content

CREATING HARDLINKS AND SOFTLINKS

There are mainly two type of links in linux that we use - hard links and soft links.
HARDLINKS
We can create hardlinks only for files.If we create hatdlink for a file the file really exist as a copy.Also syncing of contents will also occur.Eventhogh if we deleted the original file hardlink exist.Both will have different inode number.

ln test /var/hard
this command will ctrete a hardlink named hard for file test.

SOFTLINKS
We can create softlinks for files and folders.It is just a symbolic link pointing towars original file.Both will have same inode number.

ln -s test /var/soft
this command will create a softlink named soft for file test.
If the symbolic link already exist, we may get an error, to force the operation (remove exiting symbolic link), use the -f option.
ln -sf test1 /var/soft

CONVERTING HARDLINK TO SOFTLINK
To make a hard link directly into a soft link, use the -P flag like this
ln -P hardlinkname softlinkname