0

Have a directory on a hard drive where I want to change all contents from owned by root to owned by tomc. I have tried Nemo, Krusader, and Nautilus (all launched as root, using sudo), all of which claim to be able to apply such changes recursively. None do, when I check after issuing the command.

So I now have a primary dir owned by user tomc which has subdirs owned by root. In each of those subdirs are hundreds of files whose ownership needs to be tomc but is root.

I could venture to try a chmod command, but looking into this the sheer complexity of it is intimidating and even dangerous. These are backup files I'm messing with, and while not irreplaceable, I do not have a copy nor room to make one.

Is there any easy way for me to achieve what I'm wanting? I certainly am not averse to working on the command line. It just seems like a GUI is safer and surely ought to work. But it does not.

1

Although you might be adverse to using chmod commands, it is one of the most direct and simple ways of doing this. You could still run the file browser with sudo as guillermo mentioned, but there is no garuntee that it'll stick and you still need to run a command in the command line to start it with sudo.

chown -R tomcat <DIRECTORY>

This is the simplest way to change the owner of every file and directory inside a directory to user tomcat. To put you at ease of exactly what it is doing, let's look at the man page.

man chown

The syntax of the command is:chown [OPTION]... [OWNER][:[GROUP]] FILE...

We have called chown with the -R option, have selected tomcat as the owner, and the file is a directory of your choosing.

Looking at the man pages, the -R flag: -R, --recursive operate on files and directories recursively

If you would like, you could even use the -v flag to show exactly what it has done. Making the new command chown -Rv tomcat <DIRECTORY>

man: -v, --verbose output a diagnostic for every file processed

0

In Linux the console tools are often older, more stable, and better-supported than the GUI tools. Also performing root operations in a GUI is just as dangerous as performing them on the command line. Which isn't dangerous at all in this case. If you have sudo access then you can bypass permissions and ownership checks anyway so there's no way to do something you can't undo later as long as you stick to permissions commands.

sudo chown tomc -R foo

Where foo is the path of the tree, should perform literally exactly the operation you want.

0

Apologies for the format, I'm currently using my phone.

Let's say you have /home/, in this directory there are 2 folders, folder1 & folder2, both owned by root.

To change all the files that reside with in folder1 you would use the following command chown -cR tomc:root /home/folder1/ The -c option will print the changes. From root:root to tomc:root The -R means recursive, so anything inside folder1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.