SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,245
    Mentioned
    156 Post(s)
    Tagged
    1 Thread(s)

    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:
    Code:
    $ 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)
    Code:
    $ sudo rm myweirdfiles-NoGrp/myweirdfile._.part01.rar 
    rm: cannot remove `myweirdfiles-NoGrp/myweirdfile._..part01.rar': No such file or directory
    Thoughts?

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,270
    Mentioned
    197 Post(s)
    Tagged
    3 Thread(s)
    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".

  3. #3
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,331
    Mentioned
    463 Post(s)
    Tagged
    8 Thread(s)
    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.

  4. #4
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,245
    Mentioned
    156 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Mittineague View Post
    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".
    Definitely isn't a symbolic link, that would have been apparent in the ls -la command.

    Quote Originally Posted by ralph.m View Post
    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.
    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.

  5. #5
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,245
    Mentioned
    156 Post(s)
    Tagged
    1 Thread(s)
    Okay, still can't delete them, but now I know why! They have an odd character in the filename. Here is the FTP output
    Code:
    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)

  6. #6
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,245
    Mentioned
    156 Post(s)
    Tagged
    1 Thread(s)
    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!

  7. #7
    SitePoint Member
    Join Date
    Jul 2013
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I guess it would have worked by escaping the weird character with \, like:

    Code:
    rm -f myweirdfiles-NoGrp/myweirdfile.\_.part01.rar
    Where "_" would be the weird char.

  8. #8
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,245
    Mentioned
    156 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by infinitnet View Post
    I guess it would have worked by escaping the weird character with \, like:

    Code:
    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

    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...

  9. #9
    SitePoint Member
    Join Date
    Jul 2013
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  10. #10
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,245
    Mentioned
    156 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by infinitnet View Post
    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. That is one thing I didn't consider trying.

  11. #11
    SitePoint Member
    Join Date
    Jul 2013
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  12. #12
    SitePoint Addict
    Join Date
    Apr 2009
    Posts
    359
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Another tool, mc (midnight commander) from the command line usually can delete files with unusual characters in the filename too.
    Doug G
    =====
    "If you ain't the lead dog, the view is always the same - Anon


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •