Score:1

Cannot delete file, because it doesn't exist -- even if I say "rm *" -- and chmod works

cn flag

I have a file, cover.jpg, which I want to delete.

If I run rm cover.jpg, I get the error "rm: cannot remove 'cover.jpg': No such file or directory."

If I run rm *.jpg, I get the same error.

If I type rm c and tab-complete, I get the same error.

If I run ls -1b, the file's name appears as cover.jpg, entirely normally.

If I run chmod 555 cover.jpg, it works fine.

find -name cover.jpg finds the file, but find -name cover.jpg -exec rm {} \; gives the same error.

I have full permissions on the directory it is in, and can happily delete all the other files in it, or create new ones.

rm -f fails to delete the file.

I cannot use lsattr or chattr on it.

What else can I try? I've reached the third page of Google without finding anything that helped.

vanadium avatar
cn flag
1) Include some diagnostic output such as `ls -l`, `lsattr <file>`, `file <file>` in your question, otherwise there is nothing anyone could check. 2) include copied terminal output of both your command and its output.
sancho.s ReinstateMonicaCellio avatar
Avoid "narrating" what you get. Simply copy-paste commands entered and output.
sudodus avatar
jp flag
How was the file created? Did you create it or was it created automatically by some tool, that you know, or was it 'suddenly' there? What file system is it? Have you checked that the file system is healthy? Can you watch the file as a picture with some tool, for example `eog`? Could the file be opened by some program?
Score:1

Take advantage of the commands with "positive" results to understand the case. There might be an extra special character (e.g., blank) in the file name. You could count characters to check this.

Post the output of

$ find . -maxdepth 1 -name cover.jpg
$ find . -maxdepth 1 -name "cover.jpg"
$ find . -maxdepth 1 -name cover.jpg | wc -c
$ find . -maxdepth 1 -name "cover.jpg" | wc -c
$ ls -1b | grep cover
$ ls -1b | grep cover | wc -c
$ ls -1b cover*
$ ls -al cover*
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.