Linux – find a file by inode number
Posted by danielSep 4
In Linux, the find command is most commonly used to search files using different criteria such as file name, size and modified time. Did you know that you can search files using inode number as well? Here is how to do it?
With “ls” we can find the inode number –
$ ls -li /etc/hosts
1576843 -rw-r--r-- 1 root root 311 Jan 21 2017 /etc/hosts
Using “-inum” option of find command, we can locate the filename and its path by its inode number.
$ find /etc -type f -inum 1576843 2>/dev/null
/etc/hosts
$ cat $(find /etc -type f -inum 1576843 2>/dev/null)
127.0.0.1 localhost
127.0.1.1 ubuntu
No comments
You must be logged in to post a comment.