Linux: Can't delete a folder or its contents

Okay, this is a first for me, but I can’t delete this one folder and its contents on my NAS and it just blows my mind.

Here is the output of ls -la and the delete command:

$ ls -la
drwxr-xr-x 0 cpradio family         0 Sep  3 21:44 myweirdfiles-NoGrp
$ ls -la myweirdfiles-NoGrp/
total 1308696
drwxr-xr-x 0 cpradio family        0 Sep  3 21:44 .
drwxr-xr-x 1 cpradio family        0 Sep 20 20:55 ..
-rwxr-xr-x 0 cpradio family 99614720 Jun 27 09:51 myweirdfile._.part01.rar
-rwxr-xr-x 0 cpradio family 99614720 Jun 27 09:52 myweirdfile._.part02.rar
-rwxr-xr-x 0 cpradio family 99614720 Jun 27 09:54 myweirdfile._.part03.rar
-rwxr-xr-x 0 cpradio family 99614720 Jun 27 09:55 myweirdfile._.part04.rar
-rwxr-xr-x 0 cpradio family 99614720 Jun 27 09:57 myweirdfile._.part05.rar
-rwxr-xr-x 0 cpradio family 99614720 Jun 27 09:58 myweirdfile._.part06.rar
-rwxr-xr-x 0 cpradio family 99614720 Jun 27 10:00 myweirdfile._.part07.rar
-rwxr-xr-x 0 cpradio family 99614720 Jun 27 10:01 myweirdfile._.part08.rar
-rwxr-xr-x 0 cpradio family 99614720 Jun 27 10:02 myweirdfile._.part09.rar
-rwxr-xr-x 0 cpradio family 99614720 Jun 27 10:04 myweirdfile._.part10.rar
-rwxr-xr-x 0 cpradio family 99614720 Jun 27 10:05 myweirdfile._.part11.rar
-rwxr-xr-x 0 cpradio family 99614720 Jun 27 10:07 myweirdfile._.part12.rar
-rwxr-xr-x 0 cpradio family 99614720 Jun 27 10:08 myweirdfile._.part13.rar
-rwxr-xr-x 0 cpradio family 45109370 Jun 27 10:09 myweirdfile._.part14.rar
$ sudo rm -vRf myweirdfiles-NoGrp/
[sudo] password for user: 
rm: cannot remove `myweirdfiles-NoGrp': Directory not empty

Even when I rm a specific file, it doesn’t actually get deleted… (it states, no such file or directory)

$ sudo rm myweirdfiles-NoGrp/myweirdfile._.part01.rar 
rm: cannot remove `myweirdfiles-NoGrp/myweirdfile._..part01.rar': No such file or directory

Thoughts?

The closest thing I ever encountered like this was when I noticed a file using my site host’s FTP panel.

Ended up it was a “symbolic link”.

I know nothing about this stuff, so this is probably no help, but going on the title alone, I occasionally have that problem, and for me it’s a permissions thing. I have to go in and change the permissions on the file or directory to delete it.

Definitely isn’t a symbolic link, that would have been apparent in the ls -la command.

Yeah, but sudo should trump any permission issues shouldn’t it? If I can’t delete it using sudo and root is disabled… what is left? I’ve never had this happen to me before… Granted, maybe I need to actually login to the NAS directly to see if I can’t remove it there and it is a CIFS issue… hmm… I’ll try that real quick.

Okay, still can’t delete them, but now I know why! They have an odd character in the filename. Here is the FTP output

ftp> mdelete myweirdfile.*
mdelete myweirdfile.�.rar? y
550 myweirdfile.�.part08.rar: No such file or directory
mdelete myweirdfile.�.part09.rar? y
550 myweirdfile.�.part09.rar: No such file or directory
mdelete myweirdfile.�.part07.rar? y
550 myweirdfile.�.part07.rar: No such file or directory
mdelete myweirdfile.�.part05.rar? y
550 myweirdfile.�.part05.rar: No such file or directory
mdelete myweirdfile.�.part03.rar? y
550 myweirdfile.�.part03.rar: No such file or directory
mdelete myweirdfile.�.part13.rar? y
550 myweirdfile.�.part13.rar: No such file or directory
mdelete myweirdfile.�.part10.rar? y
550 myweirdfile.�.part10.rar: No such file or directory
mdelete myweirdfile.�.part12.rar? y
550 myweirdfile.�.part12.rar: No such file or directory
mdelete myweirdfile.�.part11.rar? y
550 myweirdfile.�.part11.rar: No such file or directory
mdelete myweirdfile.�.part04.rar? y
550 myweirdfile.�.part04.rar: No such file or directory
mdelete myweirdfile.�.part14.rar? y
550 myweirdfile.�.part14.rar: No such file or directory
mdelete myweirdfile.�.part02.rar? y
550 myweirdfile.�.part02.rar: No such file or directory
mdelete myweirdfile.�.part01.rar? y
550 myweirdfile.�.part01.rar: No such file or directory
mdelete myweirdfile.�.part06.rar? y
550 myweirdfile.�.part06.rar: No such file or directory

Anyone know how to deal with these? It seems to be a unicode/ascii issue (maybe)

Got it! Oddly enough, connecting to the NAS over a shared folder and deleting it from a Windows box works. Strange that I can’t delete it from a Linux box or on the NAS itself… Whatever Windows sent as the delete command worked like a charm!

I guess it would have worked by escaping the weird character with \, like:

rm -f myweirdfiles-NoGrp/myweirdfile.\\_.part01.rar

Where “_” would be the weird char.

Nope. Did that plenty of times, the files always remained. I still haven’t a clue what character or encoding the character was in that caused it to not be deleted on Linux, but now that it is gone, I’m happy :slight_smile:

Part of the issue could be that I couldn’t tell what the character was supposed to be, so I could never match the filename. What really strikes me as odd, is even telling it to remove ALL of the files via wildcard didn’t work…

Well, rm still reads each single file name and apparently the charset was that messed up, that none of the pipes was able to read/process it properly. Another option would have been to just move the upper folder to /dev/null.

I’ll have to try that should this ever happen again. :slight_smile: That is one thing I didn’t consider trying.

I’m quite certain this would have worked, as it wouldn’t have processed each single file, but only the location of the folder. Glad I was able to figure something you didn’t try. :slight_smile:

Another tool, mc (midnight commander) from the command line usually can delete files with unusual characters in the filename too.