How do I delete a protected directory?

Discussion in 'all things UNIX' started by bellgamin, Jun 3, 2024.

  1. bellgamin

    bellgamin Registered Member

    Joined:
    Aug 1, 2002
    Posts:
    8,116
    Location:
    Hawaii
    I use Rescuezilla to image my system drive on a weekly basis. I image to an external SSD.

    After I have accumulated 5 successive weekly images, I want to delete the oldest weekly image and replace it with the latest weekly image.

    Each image is a directory that includes numerous files developed by Rescuezilla while making the image. Thus, to delete the oldest image, I must delete its directory.

    PROBLEM: When I try to delete the oldest directory, it is Protected and cannot be deleted.

    QUESTION: How do I delete a Protected directory?
     
  2. n8chavez

    n8chavez Registered Member

    Joined:
    Jul 19, 2003
    Posts:
    3,539
    Location:
    Location Unknown
    In order to answer that we must know what is doing the protecting. Rescuezilla is not, since it images cold, and functions in a bootable linux environment. So what's protecting the image directory?
     
  3. bellgamin

    bellgamin Registered Member

    Joined:
    Aug 1, 2002
    Posts:
    8,116
    Location:
    Hawaii
    Hello N8 -- I do not know what is doing the protecting. I assume it is Rescuezilla because that's the program that created the directory & its files. The only message I get when trying to delete it is as follows:
     
  4. n8chavez

    n8chavez Registered Member

    Joined:
    Jul 19, 2003
    Posts:
    3,539
    Location:
    Location Unknown
    I don't think rescuezilla can do that. It's not an installed program. It comes as an image file, .iso, right? In that case it's not installable and functions only as a bootable medium. That means it cannot install any service/driver that would be needed to protect the folder because it's read-only. I suspect you're using permissions from linux on that folder that are preventing you from deleting.
     
  5. bellgamin

    bellgamin Registered Member

    Joined:
    Aug 1, 2002
    Posts:
    8,116
    Location:
    Hawaii
    You are correct that I downloaded Rescuezilla (Rz) as an iso file. I used that iso file to create a bootable USB that runs Rz.

    I used Zorin's File Management app to create the directory folder wherein Rz created yet another directory to hold that particular image. I had NOTHING to do with permissions for that image's directory because Rz created that directory, not me.

    From the time I began using Linux until now, I have never dealt with setting or modifying permissions. I am at a loss to even guess what added the permission requirement to the directory created by Rz. I still hope that someone can tell me how to delete that directory.
     
  6. n8chavez

    n8chavez Registered Member

    Joined:
    Jul 19, 2003
    Posts:
    3,539
    Location:
    Location Unknown
    I still say the issue is with linux itself. I downloaded RZ, added it to e2b, ran it, and created a complete backup on another drive. Then I rebooted back in to Windows 11. I saw my backup, seen below. I was able to delete any file I wanted to, even the entire directory. That tells me the issue is not RZ, but your local OS, since it's the only differing variable.

    Screenshot 2024-06-03 233321.png
     
  7. bellgamin

    bellgamin Registered Member

    Joined:
    Aug 1, 2002
    Posts:
    8,116
    Location:
    Hawaii
    Thanks N8. I will check with the Zorin forum to see what they have to say.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Back in the bad old days, when I ran Windows, I could remove the protection for ANY file or directory by doing so as Admin. I was hoping there was some such on Linux -- like some sudo command on the terminal -- or maybe some way to become a "super user."

    Is there? Anybody?
     
  8. Stupendous Man

    Stupendous Man Registered Member

    Joined:
    Aug 1, 2010
    Posts:
    2,962
    Location:
    the Netherlands
    Hi bellgamin,

    I suppose it is the same as it is with using Clonezilla.
    The images created using Clonezilla (directories including multiple files) are created with root ownership.
    When in my file manager I right-click a Clonezilla image, select Properties, Permissions, I can see the image has root ownership.

    I suppose there may be several ways to get root privileges to be able to delete a Clonezilla image, or in your case, a Rescuezilla image.

    I use the application Krusader and its Root Mode option to be able to delete Clonezilla images.
    https://krusader.org/
    https://docs.kde.org/stable5/en/krusader/krusader/index.html
    https://docs.kde.org/stable5/en/krusader/krusader/tools-menu.html#root-mode

    I use Krusader like this:
    open Krusader;
    go to Tools;
    select: Start Root Mode Krusader (or use: Alt+Shift+K)
    Continue;
    enter your password + OK.
    A new window opens: Krusader - ROOT PRIVILEGES.
    In this Krusader window with root privileges, you can navigate to the directory in which you have your Rescuezilla images, right-click the image you want to delete, select Delete, Delete, Delete All.

    Next you can quit the Krusader window with root privileges, and quit the primary Krusader window.

    Using Krusader and its Root Mode option to delete Clonezilla images works great for me.
    But as I said, I suppose there may be other ways to get root privileges to be able to delete a Rescuezilla image.
     
  9. bellgamin

    bellgamin Registered Member

    Joined:
    Aug 1, 2002
    Posts:
    8,116
    Location:
    Hawaii
    Krusader was pre-loaded on my Zorin Pro distro of Linux. However, Krusader seems to want KDE. I could not get it to work effectively with Zorin. For instance, when I activated Krusader's root tool, it would not accept my Password that I use on Zorin.

    I *think* I have a work-around but, first, I am joining Source Forge so that I can post this issue to Rescuezilla's forum.

    MANY thanks for your counsel, @Stupendous Man !!! If I weren't such a novice with Linux, I'm sure I could have got Krusader working for me.

    BTW, I did get root privileges -- by using "sudo su" & my password, followed by "whoami" whereby the terminal said "Root". Even as root, I still couldn't delete the image's directory because Permissions tab states that I am not that directory's owner -- Rescuezilla is. Ergo, I think Krusader wanted Rescuezilla's password in order to activate Krusader's image root tool. But that's just a guess on my part -- I am very much a beginner when it comes to the inner workings of Linux's built-in security features.
     
    Last edited: Jun 5, 2024
  10. Stupendous Man

    Stupendous Man Registered Member

    Joined:
    Aug 1, 2010
    Posts:
    2,962
    Location:
    the Netherlands
    Oh, bellgamin, what a pity things are so complicated.

    I made me wonder if perhaps your Zorin installation uses separate user and root passwords. Do you remember creating both, when you installed Zorin OS? In that case, you may need the root password to use Krusader's Root Mode.

    But as you say you got root privileges in the terminal and still couldn't delete Rescuezilla images, and the images directory Permissions tab states Rescuezilla is owner, things seem quite complicated.

    I'm sorry I wasn't able to help.
    I hope the Rescuezilla Sourceforge forum members say it's not complicated at all and know exactly what to do.
     
  11. Brian K

    Brian K Imaging Specialist

    Joined:
    Jan 28, 2005
    Posts:
    12,387
    Location:
    NSW, Australia
    bellgamin,

    You own IFL. It contains TeraByte Explorer which will delete those directories. TBWinRE also contains TeraByte Explorer.
     
  12. XIII

    XIII Registered Member

    Joined:
    Jan 12, 2009
    Posts:
    1,393
    Maybe I misunderstood, but did you perhaps become root in a terminal and tried deleting folders in a GUI (where you still are a regular user) instead of on the command line?
     
  13. summerheat

    summerheat Registered Member

    Joined:
    May 16, 2015
    Posts:
    2,221
    You can try to change the owner with the chown command (as root or with sudo).

    It's also possible that you still cannot delete that directory as root because it might additionally be protected with the immutable attribute "i" with chattr. You can check this by executing lsattr for this directory. You will probably see an "i" in the output. In order to change that you can execute chattr -i <directory> as root or possibly chattr -iR <directory> to recursively change the attributes of the content in that directory.
     
  14. bellgamin

    bellgamin Registered Member

    Joined:
    Aug 1, 2002
    Posts:
    8,116
    Location:
    Hawaii
    @XIII -- you are correct: after becoming root, I tried to delete the directory in the GUI.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    @ All who helped me: Based on your suggestions & comments, I *FINALLY* learned how to delete a Rescuezilla-protected directory using the terminal!!! :thumb::thumb::thumb: I did so as follows:

    On the terminal, I did SUDO SU (password) then I did RM -R (directory name)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    BTW: Is there any way to copy & paste text into the terminal? I ask this because some directory names are lengthy.
     
  15. Stupendous Man

    Stupendous Man Registered Member

    Joined:
    Aug 1, 2010
    Posts:
    2,962
    Location:
    the Netherlands
    Ah, good.
    Looking for a solution, I read about that, but I wasn't sure at all if that was the right solution for your situation.

    I don't know if this depends on which terminal.
    In 'Konsole', on Kubuntu, I can paste using the context menu (right-click) and select Paste (or Ctrl+Shift+V).
    I don't know if this works the same way in other terminal.
     
  16. bellgamin

    bellgamin Registered Member

    Joined:
    Aug 1, 2002
    Posts:
    8,116
    Location:
    Hawaii
    @Stupendous Man Thanks to you, I can now C&P. :thumb::thumb::thumb: I had no idea that the Terminal responds to a right click.
     
  17. Stupendous Man

    Stupendous Man Registered Member

    Joined:
    Aug 1, 2010
    Posts:
    2,962
    Location:
    the Netherlands
    Great! I didn't know if that would work the same way in other terminal than Konsole.
     
  18. wat0114

    wat0114 Registered Member

    Joined:
    Aug 5, 2012
    Posts:
    4,095
    Location:
    Canada
    As @summerheat mentioned, chown command should work as well. An example I used recently to change ownership of a text file on my Desktop:

    sudo chown -R myusername:myusername opt.brave.com.brave.brave-browser.txt

    The chmod command is a good one to know as well:

    https://www.howtogeek.com/437958/how-to-use-the-chmod-command-on-linux/
     
  19. xxJackxx

    xxJackxx Registered Member

    Joined:
    Oct 23, 2008
    Posts:
    8,912
    Location:
    USA
    FYI I have found it to work in pretty much any Terminal I have used, including the WHM Terminal on our web server which runs in a web browser.
     
  20. Stupendous Man

    Stupendous Man Registered Member

    Joined:
    Aug 1, 2010
    Posts:
    2,962
    Location:
    the Netherlands
    Ah, thanks, that is good to know.
     
  21. summerheat

    summerheat Registered Member

    Joined:
    May 16, 2015
    Posts:
    2,221
    I'm sure that you did not ... as Linux commands are case sensitive :D

    But I'm glad that you solved the problem. It's good that @XIII had a hunch that the graphical application was still running as user.
     
  22. xxJackxx

    xxJackxx Registered Member

    Joined:
    Oct 23, 2008
    Posts:
    8,912
    Location:
    USA
    True story and good catch. :D
     
  23. bellgamin

    bellgamin Registered Member

    Joined:
    Aug 1, 2002
    Posts:
    8,116
    Location:
    Hawaii
    @wat0114 -- I have made a computer file that covers useful stuff I have learned about Linux, including a special section covering the terminal. I have added your info thereto -- plus several other helpful ideas that I have learned from comments in this thread.

    I did the same thing when learning Windows & (in days of yore) Forth, MS DOS, and Pascal.

    @summerheat -- yes, I did NOT capitalize commands in the terminal. I did so in my comments, here at Wilders, so as to make the commands easy to spot. Next time I will do so by a different method so as not, potentially, to mislead.

    Speaking of syntax: "Let's eat Grandma" is quite different from "Let's eat, Grandma." (Among carnivores, proper syntax saves lives.)
     
    Last edited: Jun 6, 2024
  24. reasonablePrivacy

    reasonablePrivacy Registered Member

    Joined:
    Oct 7, 2017
    Posts:
    2,124
    Location:
    Member state of European Union
    Be aware that space is a separator for command arguments, so in case of file or directory containing space be sure to surround path with a pair of ' (I hope this is right character, I am on phone)
    or escape character meaning prepending with /
    It is especially important for rm command!
     
  25. bellgamin

    bellgamin Registered Member

    Joined:
    Aug 1, 2002
    Posts:
    8,116
    Location:
    Hawaii
    @reasonablePrivacy -- Many thanks for the tip. I have C&P'd it to my file of terminal howto's.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.