Let's say the ln command was used to create a symblic link between /home/john.doe/foo.txt and /home/jane.doe/bar.txt.
ln -s /home/john.doe/foo.txt /home/jane.doe/bar.txt
The ls (list) command with the -l (long) flag can be used to see that /home/john.doe/foo.txt is now symbolically linked to /home/jane.doe/bar.txt.
~]# ls -l /home/jane.doe/bar.txt
lrwxrwxrwx. 1 jane.doe jane.doe 183 May 23 18:53 /home/jane.doe/bar.txt -> /home/john.doe/foo.txt
/home/jane.doe/bar.txt will now show as being linked to /home/john.doe/foo.txt.
/home/john.doe/foo.txt will not show as being linked to /home/jane.doe/bar.txt.
~]# ls -l /home/john.doe/foo.txt
-rw-r--r--. 1 john.doe john.doe 123456 Oct 26 15:38 /home/john.doe/foo.txt
~]# ls -l /home/jane.doe/bar.txt
lrwxrwxrwx. 1 jane.doe jane.doe 183 May 23 18:53 bar.txt -> /home/john.doe/foo.txt
Every unique file in Linux has a unique inode number.
In this example, the inode of /home/john.doe/foo.txt is 33554566.
~]# ls -i /home/john.doe/foo.txt
33554566 foo.txt
And /home/jane.doe/bar.txt has a different inode, 15422514 in this example.
~]# ls -i /home/jane.doe/bar.txt
15422514 bar.txt
This shows that /home/john.doe/foo.txt and /home/jane.doe/bar.txt are not the same file.
The unlink command can be used to remove the symbolic link.
unlink /home/jane.doe/bar.txt
The ls (list) command with the -l (long) flag can be used to see that /home/john.doe/foo.txt is no longer linked to /home/jane.doe/bar.txt.
~]# ls -l /home/john.doe/foo.txt
-rw-rw-r--. 1 john.doe john.doe 183 May 23 18:53 file.txt
Did you find this article helpful?
If so, consider buying me a coffee over at