Ubuntu – Can’t delete file even as root

12.04deletefilesfilesystemrm

I tried to delete a directory by running sudo rm -rf google-chrome. This gave no output message but the directory wasn't deleted. There is only one file remaining, google-chrome/default/User\ StyleSheets/Custom.css.

I tried to cd to the User\ Stylesheets directory and remove the file but that didn't work.

I ran sudo rm Custom.css, but the file wasn't deleted (and no output from rm).

How can I delete it?

More info:
ls -la Custom.css gives

    -rw-rw-r-- 1 david david 0 Oct 21 02:42 Custom.css

lsattr Custom.css gives

    -------------e- Custom.css

(the immutable bit is not set)

Best Answer

Most likely some process is holding the file open and/or immediately recreating it when you delete it. Try the following command:

sudo lsof google-chrome/default/User\ StyleSheets/Custom.css

This should tell you what program is locking the file. You may then kill it, and (hopefully) delete the file. Failing that, a reboot should fix it good.

Related Question