Deleting a particular user files /userid

  • Follow


Hi,
Iam interetsed in learning Unix administration stuff.
Suppose a person left a company and we need to delete all his files.
How typically we can achieve this.
I think we can find all his files by using find command with -user
option.
Is there any better way to perform the same job?

0
Reply balreddy.gattu (4) 6/21/2006 6:42:36 PM

balreddy.gattu@gmail.com wrote:
> Hi,
> Iam interetsed in learning Unix administration stuff.
> Suppose a person left a company and we need to delete all his files.
> How typically we can achieve this.
> I think we can find all his files by using find command with -user
> option.
> Is there any better way to perform the same job?
> 

That's generally what's done.
0
Reply base60 6/21/2006 7:01:34 PM


On 21 Jun 2006 11:42:36 -0700, balreddy.gattu@gmail.com <balreddy.gattu@gmail.com> wrote:
> Hi,
> Iam interetsed in learning Unix administration stuff.
> Suppose a person left a company and we need to delete all his files.
> How typically we can achieve this.
> I think we can find all his files by using find command with -user
> option.

Yes, and look at coupling that with -exec and xargs.

> Is there any better way to perform the same job?

Not that I know of, unless you count the above as "better".  You can do
this as a one-liner it'll just take a while to run.
0
Reply Dave 6/21/2006 7:03:28 PM

In article <4ftjg0F1kjrv8U2@individual.net>, Dave Hinz wrote:
> On 21 Jun 2006 11:42:36 -0700, balreddy.gattu@gmail.com <balreddy.gattu@gmail.com> wrote:
>> Hi,
>> Iam interetsed in learning Unix administration stuff.
>> Suppose a person left a company and we need to delete all his files.
>> How typically we can achieve this.
>> I think we can find all his files by using find command with -user
>> option.
> 
> Yes, and look at coupling that with -exec and xargs.

That should really be 'exec OR xargs'... :)

>> Is there any better way to perform the same job?
> 
> Not that I know of, unless you count the above as "better".  You can do
> this as a one-liner it'll just take a while to run.

Kevin

-- 
Unix Guy Consulting, LLC
Unix and Linux Automation, Shell, Perl and CGI scripting
http://www.unix-guy.com
0
Reply Kevin 6/21/2006 7:16:10 PM

On Wed, 21 Jun 2006 19:16:10 GMT, Kevin Collins <spamtotrash@toomuchfiction.com> wrote:
> In article <4ftjg0F1kjrv8U2@individual.net>, Dave Hinz wrote:

>> Yes, and look at coupling that with -exec and xargs.
>
> That should really be 'exec OR xargs'... :)

Fair enough.  We're saying the same thing but diagraming the equation
differently, I think.


0
Reply Dave 6/21/2006 7:33:11 PM

balreddy.gattu@gmail.com wrote:
> Hi,
> Iam interetsed in learning Unix administration stuff.
> Suppose a person left a company and we need to delete all his files.
> How typically we can achieve this.
> I think we can find all his files by using find command with -user
> option.
> Is there any better way to perform the same job?
> 

Other users might continue to work with the files that are owned by
the user who has left.

You need a policy first.
A policy can e.g. say: leave the user's files in shared group/project
directories, but delete the personal files in the user's home directory.

-- 
Michael Tosch @ hp : com
0
Reply Michael 6/21/2006 7:35:50 PM

On Wed, 21 Jun 2006 19:16:10 GMT, Kevin Collins wrote:
> In article <4ftjg0F1kjrv8U2@individual.net>, Dave Hinz wrote:
>> On 21 Jun 2006 11:42:36 -0700, balreddy.gattu@gmail.com <balreddy.gattu@gmail.com> wrote:
>>> Hi,
>>> Iam interetsed in learning Unix administration stuff.
>>> Suppose a person left a company and we need to delete all his files.
>>> How typically we can achieve this.
>>> I think we can find all his files by using find command with -user
>>> option.
>> 
>> Yes, and look at coupling that with -exec and xargs.
>
> That should really be 'exec OR xargs'... :)
[...]

Actually, that should really be -exec AND NOT xargs, unless you
have one of those find/xargs variants that support -print0/-0 as
the GNU or recent BSD ones.

And you need to treat regular files and directories differently
(and use -depth), and if a directory that user owns contains
files owned by other users, you need to decide what to do (chown
root, chmod u-s for instance).

-- 
Stephane
0
Reply Stephane 6/22/2006 10:41:51 AM

Dave Hinz wrote:
> balreddy.gattu@gmail.com wrote:
>
> > Iam interetsed in learning Unix administration stuff.
> > Suppose a person left a company and we need to delete all his files.
> > How typically we can achieve this.
> > I think we can find all his files by using find command with -user
> > option.
>
> Yes, and look at coupling that with -exec and xargs.

As you already posted s/and/or/.  I will add that learning "find" is
one of the best learning tasks a new sysadmin can do.  Binary
descent tree with algebraic groupings on the command line.
Wonderfull stuff.

> > Is there any better way to perform the same job?
>
> Not that I know of, unless you count the above as "better".  You can do
> this as a one-liner it'll just take a while to run.

For better I would add in getting most of the way there faster and
easier - Archive to tape and delete that user's home directory.  Most
of the owned files will be there and in the various tmp directories.
Outside of the various tmp directories I would not want to
automatically
delete any owned file.  I've had senior CAD users own an entire CAD
application, delete automatically by owner and kaboom.

Del home dir.  Autodelete out of tmp dirs.  Search without auto
del elsewhere.  Expect to find a few owned files in other home dirs
from trading files among users.

0
Reply Doug 6/22/2006 6:45:14 PM

7 Replies
237 Views

(page loaded in 0.105 seconds)

5/23/2013 8:48:48 AM


Reply: