Delete files by inode number

An inode identifies a file and its attributes including size, owner, permissions, etc. Inode number is unique within a file system, to be specified, we can also call it partition.
Normaly, we use rm to delete files, is there any necessary to remove files by inode? I’d say yes there is!
On the common linux filesystem ext3, it’s allowed to use control characters or characters which are unable to be input on a keyboard or special character such as ^, /, ?, * as a file name.
When using rm, it’s not so convinent to delete these files, and mostly it’s problematic to find out an solution. Using following commands to delete the files are really effective and easy:

Please keep note that the following commands also work on Solaris, FreeBSD and any other Unix-linux-like operation systems:

First find out file inode number with any one of the following command:

stat file-name OR ls -il file-name

If you cannot type the file name, just use * instead of file-name.
Use find command as follows to find and remove a specified file:

find . -inum [inode-number] -exec rm -i {} \;

When prompted for confirmation, press Y to confirm removal of the file.

If you have filename like name “2009/03/21” then no UNIX/Linux command can delete this file by name. The only way to delete such file is to delete it by inode number.
Linux or UNIX never allows creating filename like 2009/03/21 but if you are using NFS from MAC OS or Windows then it is possible to create such file too.

Share this post

12 thoughts on “Delete files by inode number

  1. @goodjob.. Oops, I’m feeling sorry for this issue. Without back-slant, this command is really problematic. I’d pay more attention next time..

  2. グッチ メンズ · Edit

    Howdy just wanted to give you a quick heads up. The text in your post seem to be running off
    the screen in Chrome. I’m not sure if this is a format issue or something to do with internet browser compatibility but I thought I’d post to let you know. The design and style look great though! Hope you get the issue solved soon. Many thanks

  3. Hello to every one, since I am truly keen of reading
    this web site’s post to be updated regularly. It contains pleasant material.

  4. If some one needs expert view on the topic
    of blogging afterward i propose him/her to pay a visit this web site, Keep up the fastidious job.

Post Comment