Deleting a File Using the Inode Number

Sometimes you will accidentally create a file that has special characters in the file name which then prevents you from running commands on it.  In that case, you can resort to accessing the file via it’s inode number.

To do so:

$ ls -il | more

In the directory in which the file that you want to examine resides

This will output a list of files, the first column being the inode number.

You can then run the following command to delete it, where 123456789 is the inode number:

$ find . -inum 123456789 -exec rm -i {} \;

Of course, you can -exec other commands to modify the file as well.

Leave a Reply