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. |
Code:
find /dir -type f -uid 1256 -exec chown user:grp {} \; |
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. |