You can make links between files in Linux. There are two types of links: hard links and symbolic links. In this tutorial I will show you the differences between the two and how to create them.

Introduction

You can link files and directories, so any changes in one file (the source) will be reflected in the other file (the target). There are two types of links: hard links and symbolic links.

Hard links are only possible with files on the same drive. You can use ln or link commands to create a hard link:

ln SOURCE TARGET
link SOURCE TARGET
  • SOURCE and TARGET are file paths.

If you remove the source file, target file will remain with the contents of the deleted file.

You can link folders and files on the same or different drives with symbolic links. You can use ln -s to create a symbolic link:

ln -s SOURCE TARGET

If you remove the source file, target file will be unusable.