Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Server
User Name
Linux - Server This forum is for the discussion of Linux Software used in a server related context.


  Search this Thread
Old 03-20-2009, 04:40 PM   #1
Registered: Sep 2005
Posts: 128

Rep: Reputation: 15
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.
Old 03-20-2009, 05:18 PM   #2
TBC Cosmo
Registered: Feb 2004
Location: NY
Distribution: Fedora 10, CentOS 5.4, Debian 5 Sparc64
Posts: 355

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

Last edited by TBC Cosmo; 03-20-2009 at 05:20 PM.
Old 03-20-2009, 06:48 PM   #3
Senior Member
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
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.

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.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Find the space for files owned by specific users sahil.jammu Linux - Newbie 15 03-04-2009 02:15 PM
root-owned file is able to be deleted with my non-root account win32sux Linux - Security 3 11-18-2008 03:00 AM
all users have access to root owned files sakatola Linux - Security 2 07-22-2005 01:45 AM
Samba logs files deleted by users?? Goma_2 Linux - Software 0 09-22-2003 07:37 AM
Un-Owned files? Half_Elf Linux - General 3 05-19-2003 12:26 AM > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 03:26 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration