Using sudo nautilus
I created some folders and I want to get rid of root permission on them. But I have many and I want to do it to a entire directory and its containing folders.
So how to allow read/write to current user to all files and folders inside a specific directory that is inside /home
?
To revert damage done using
sudo nautilus
you should make yourself the owner of any directories (and their contents) that are owned by root.You can use
find
to do this, as it has a test to find only files owned by a specific user.This will find all the directories in your home owned by root:
You can then repeat the
find
command and add the action you want to do - recursively changing ownership of all the found directories and their contents to the current user:Explanation:
~
the home directory-type d
find only directories-user root
find only stuff belonging to root-exec
do the following command on whatever was foundsudo chown -R
recursively change owner$USER
the current user:
also change group to the specific userMore efficiently, you could omit the
-type d
to find files of any type belonging to root, and also omit the-R
asfind
will do the recursion for you by acting on all the filesRunning GUI tools, like
nautilus
asroot
is Considered Harmful for this reason, among others (hidden functions, ability to silently run program fragments from who knows where, ...).You don't have a "permission" problem, you have an "ownership" problem.
To find all the files owned by
root
(really owned by anybody else), do:To change the ownership back to you, you could
but that will change the ownership of all files in and under
$HOME
Gives one the opportunity to adjust the list of files, owned by not-you, that will have their ownership changed back to you.
What you need to do is change the ownership of the folder from the user (and group) root to the other user (and group) you want.
Imagine you want to work on /home/randomFolder, and that the user you want to handle ownership to is vitor-abella, what you need to do is simply execute this as root:
It may take a while if there's a lot of files and subfolders, but after that you should be on track.
Cheers.