How to remove files using inode number?





An inode is a data structure on a filesystem, which provides the info about the file’s metadata like file permissions, ownership, file type, block details, attributes.

Please run the following command to view the details of the inode number of files located in the present working directory.

arunlal@lintechops:/var/log$ ls -li
total 12496
524493 -rw-r--r-- 1 root root 1445 Dec 24 14:52 alternatives.log
524621 -rw-r--r-- 1 root root 5635 Nov 15 13:59 alternatives.log.1
524750 -rw-r--r-- 1 root root 396 Feb 28 2019 alternatives.log.10.gz
524353 -rw-r--r-- 1 root root 258 Jan 25 2019 alternatives.log.11.gz
524488 -rw-r--r-- 1 root root 353 Dec 12 2018 alternatives.log.12.gz
524948 -rw-r--r-- 1 root root 408 Oct 31 15:35 alternatives.log.2.gz
524513 -rw-r--r-- 1 root root 518 Sep 25 15:01 alternatives.log.3.gz

If you want to know about the inode number of a single file, please run the following command.

arunlal@lintechops:/var/log$ ls -i alternatives.log.10.gz
524750 alternatives.log.10.gz

If you wish to remove the file using inode number please run the following command.

arunlal@lintechops:/var/log$ find . -inum 524750 -exec rm -i {} \;

Post navigation

Leave a Reply