LLI Wiki — My Digital Knowledge Base

Deleting a Linux file by its inode number

Find a file's inode number with ls -li and delete it with find -inum, after checking the match.

On Linux, every file is identified by an inode number. When a file name is hard to handle (special characters, an unreadable name), you can delete the file by its inode.

Find the inode number

ls -li

The first column shows the inode number of each file.

Delete the file

Check the matches first:

find . -inum 12345678 -print

Delete the file:

find . -inum 12345678 -delete

Or ask for confirmation before each removal:

find . -inum 12345678 -exec rm -i {} \;

Notes

Mastodon LLIMastodon SocialFosstodon