We all as a system admin should know how to find all hard links to a file on our system.
So let us have a look, how to find this useful information.
There are two ways to do this task.
1. Using -samefile option of find command.
Here we will search the filesystem with -samefile option.
[root@nglinux ~]# ln /etc/passwd ./passwd_backup [root@nglinux ~]# find / -samefile /etc/passwd | more /root/passwd_backup find: `/proc/23052/task/23052/fd/5': No such file or directory find: `/proc/23052/task/23052/fdinfo/5': No such file or directory find: `/proc/23052/fd/5': No such file or directory find: `/proc/23052/fdinfo/5': No such file or directory /etc/passwd [root@nglinux ~]#
2. Using inum option if samefile option is not available with find command.
Here we will search the filesystem using inode number.
[root@nglinux ~]# ls -il /etc/passwd 663401 -rw-r--r--. 2 root root 1920 Jan 6 01:54 /etc/passwd [root@nglinux ~]# find / -inum 663401 /root/passwd_backup find: `/proc/23188/task/23188/fd/5': No such file or directory find: `/proc/23188/task/23188/fdinfo/5': No such file or directory find: `/proc/23188/fd/5': No such file or directory find: `/proc/23188/fdinfo/5': No such file or directory /etc/passwd [root@nglinux ~]#
I hope you liked the article.
Please do comment and add something to this article.
