# [Solved] change uid of a user and all the files he owns

## The_P

Hello I have the Problem that I have an NFS Server and two users on two machines have diffrent uid's but they should have the same uid. Is it possible to change the uid of all files the user owns and then change the uid of the user?Last edited by The_P on Wed Jan 04, 2006 12:14 pm; edited 1 time in total

----------

## Katphish

Yeah.  This is exactly the job for `find`.  I would `man find` and read up on it but this is the command line you want:

```
find . -uid <User ID from /etc/passwd - field 3 - or old UID> -exec chown <user name> '{}' \;
```

If you use the `find .` make sure you are in the top directory where you want to start.

If you want to change the UID locally to match the remote UID and change the file ownership too, I would

1) vipw -- this will automatically edit /etc/passwd

2) change the UID -- field 3 -- This will orphan all the files currently owned by the old UID, by that I mean they will show a UID instead of a username when you do an ls -l

3) go to your nfs exports and run the above command

4) if the user has a local home directory, I would change that too

HTH

edit to add:

heh, now that I think about, you could just use `find /` instead of `find .` and just hit everything at once   :Rolling Eyes: 

----------

## pjp

Moved from Other Things Gentoo

----------

## The_P

Thanks a lot It worked.

----------

## Katphish

 *The_P wrote:*   

> Thanks a lot It worked.

 

Cool!

I would change the title to [Solved]...

----------

