LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 03-20-2009, 03:40 PM   #1
KnightHawk
Member
 
Registered: Aug 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, 04:18 PM   #2
TBC Cosmo
Member
 
Registered: Feb 2004
Location: NY
Distribution: Fedora 10, CentOS 5.4, Debian 5 Sparc64
Posts: 355

Rep: Reputation: 43
Code:
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 04:20 PM.
 
Old 03-20-2009, 05:48 PM   #3
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora, Lubuntu, FreeBSD
Posts: 3,930
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.

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.
 
  


Reply


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 01:15 PM
root-owned file is able to be deleted with my non-root account win32sux Linux - Security 3 11-18-2008 02:00 AM
all users have access to root owned files sakatola Linux - Security 2 07-22-2005 12:45 AM
Samba logs files deleted by users?? Goma_2 Linux - Software 0 09-22-2003 06:37 AM
Un-Owned files? Half_Elf Linux - General 3 05-18-2003 11:26 PM


All times are GMT -5. The time now is 09:28 AM.

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