What is a hard and symbolic (soft) link in Linux or Unix?

Hard link vs Soft link:

Check the inodes and permissions of symbolic link:

Check the inodes and permissions of hard link:

How do I create symbolic link in Linux?

ln -s source_file my_link
ln -s /path/to/file1.txt /path/to/file2.txt
ls -s /etc/hosts /tmp/file

How do I create hard link in Linux?

ls [options] /path/to/source /path/to/link
## create a hard link ##
ln /home/vivek/my-awesome-long-file.txt /home/vivek/file

And that’s it!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store