LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Need Script to own files owned by deleted users (https://www.linuxquestions.org/questions/linux-server-73/need-script-to-own-files-owned-by-deleted-users-713217/)

KnightHawk 03-20-2009 03:40 PM

Need Script to own files owned by deleted users
 
Anyone have a script handy or can think of a way to own files in a directory that were once owned by users who have been deleted?

I do not want to take ownership of files of active users thus can't just chown root.users. But want to take ownership of files marked "1256.users" where 1256 used to be someone who is now gone.

TBC Cosmo 03-20-2009 04:18 PM

Code:

find /dir -type f -uid 1256 -exec chown user:grp {} \;
if you know what uid the user had

anomie 03-20-2009 05:48 PM

At a glance, I believe TBC Cosmo's find invocation should do the trick for you. Like anything, you'll want to test it before running it on a production system.

As a related aside, I'd recommend that you read through a brief guide I wrote up some time ago on removing/disabling old users.

http://daemonforums.org/showthread.php?t=413

It was written for FreeBSD originally, but the same commands should apply for Linux (except for chpass -- you'll need to use chage instead). There are some post-user departure steps that should be taken as a matter of policy. And you might even consider disabling (as opposed to deleting) users to keep something of an audit trail around.


All times are GMT -5. The time now is 11:46 AM.