Press "Enter" to skip to content

Find and change file owners & groups

Consolidating users or changing owners for files scattered across file systems can be a royal pain for Unix/Linux, For Winblows; I don’t even want to try and imagine the quantity of Excedrin it might take to accomplish this task (but who cares about Winblows?)

The simple solution is keyed in just as it sounds… find all the files/directories owned by user1 and chown them to user2, we’ll also say that user2 is in a new group called group2.

Sure you can do a LOT of keyboard surfing and get it accomplished, how about two short lines and let the server take care of it for you….

First you’lll need the UID (and GID) for user1 (hint look in /etc/passwd and /etc/group) and use the following commands;

find . -uid 5015 -exec chown user2 {} ;

find . -gid 5015 -exec chgrp group2 {} ;

You’d be hard pressed to accomplish this much faster and without a lot of effort.

Happy Hacking