Can I change the permissions of files that root has read only access to?

7,145

Yes, doing it as the root user would allow you to change the permissions on (and owner of) these files and directories.

$ cd /backup/dir/somewhere
$ sudo chown myname:mygroup myfile
$ sudo chmod u+rw myfile

... where myname and mygroup is your username and default group (check you other files in your home directory or use id -n -u (for username) and id -n -g (for group)), and myfile is a single file.

To do this on a whole directory, including its contents:

$ sudo chown -R myname:mygroup mydir
$ sudo chmod -R u+rw mydir

However, a directory needs to be "executable" for you to be able to cd into it. The "write" permission on a directory allows you to add or remove files to/from it, once you've entered it. With the "read" permission on a directory, you're allowed to list its contents, once you've entered it. So only having "read" and/or "write" permissions on a directory makes no sense.

Just don't do

$ sudo chmod -R u+rwx mydir      # don't

as that would make every file in there executable.

Share:
7,145

Related videos on Youtube

TARDIS Maker
Author by

TARDIS Maker

Update 2020: If you happen to stumble upon my profile, enjoy a bit of a time capsule :) It's been close to five years since this was up to date, but since I don't use the site much anymore, I think I'll leave it as it is. Have a nice day! (btw, the email isn't active anymore) Original from roughly 2016: I'm a 15 year old 3D Modeler and Generalist with about 2 years of experience. Checkout my Artstation :) Here are a few of my favorite answers Keep sharp edges when using subdivision surface How can Tris be used to an Advantage? Why is part of my model not being rendered? You can contact me at: tardismodeler(at)gmail.com

Updated on September 18, 2022

Comments

  • TARDIS Maker
    TARDIS Maker almost 2 years

    A few days ago I made the switch from Debian to Arch. When I did that, I backed up my files to an external harddrive.

    I've moved the contents of that backup to my normal harddrive. Now I'd like to delete the files on the removable harddrive so that I can use it for other things, but the permissions on those files read only:

    dr-x------

    Is there a way that I could change the permissions of these files so that I can manipulate them?