Last Updated: February 25, 2016
·
1.359K
· jdlich

How to delete files on your server with no name

The Problem

There's a file or directory on your server with no name (in my case, a directory) and you simply can't delete it. Your FTP program can't do it. And you can't do it directly with rm because it has no name!

Solution

Fortunately, files have other metadata besides their name that we can use to identify it like their inode number.

Getting the inode number

Get the inode number of the nameless file using ls -li. It's the number on the far left.

Deleting a file by its inode number

Once you have the inode number, you can delete the file using find:

find . -inum INODE_NUMBER | xargs rm -rf

Be sure to replace INODE_NUMBER with the actual inode number.