Links are about to file systems. For about that thing file systems, we should some learn inode notion at least for hard link.
When we are a create a file in Linux, that file actually be a inode. inode is basically a number in the inode table. By this number we are accessing our file. Because the file system works with these numbers for files.
Symbolic link, is basically a pointer for real files or folders. It keeps the link given to him. That links points to real file or folder. It's similar to Windows shortcuts.
ln -s file.txt link.txt
file.txtis a real file.link.txtis a symbolic link file. So, its pointsfile.txt.
So, we what writes by link.txt, actually we writes in file.txt. In that reason when we delete file.txt, the link.txt
will a dead or dangling link.
Actually, each file is a hard link associated with an inode. You can check with ls -l command in a diretory filled with
files. After the file permissions you will see a number. For example 1. So, it is the number of hard links associated with
this inode.
For example we create a file name as a file1.txt and then;
ln file1.txt file2.txt
By this command, we actually associated file1.txt's inode to with a file2.txt. We have two hard links associate to
same inode. Check number of hard links by ls -l command for file1.txt. If value is it 2 its true because we have
another hard link. So its file2.txt.
So, for example we deletes file1.txt we can keep going with file2.txt because inode has a another hard link so its
file2.txt.