chown all files of removed user (symlinks)

1

I migrated my OSX System from one machine to another. Everything works fine, but when I check the files under /usr/local, they now belong to a user 502, not my newly created user (which has the internal id 501).

Problem: even with sudo,

chown (-R) <username>:admin 

did not work, the files remain unchanged.

How can I get rid of user 502?

Update: It seems normal files/dirs are changed, but symlinks aren't.

Jan Galinski

Posted 2014-04-09T18:21:50.950

Reputation: 133

Answers

1

As you have determined yourself you need to chown the files owned by user 502 to 501. You can do this with:

find / -user 502 | xargs chown username:admin

This will find all files and directories owned by user 501 and chown them to username:admin.

mtak

Posted 2014-04-09T18:21:50.950

Reputation: 11 805

Thank you ... while this helped a lot, all symlinks (and thats many, since I am in the brew Cellar) are not changed. I will update the question. – Jan Galinski – 2014-04-09T20:06:44.067

You can update symlinks with with chown -h username:admin filename – mtak – 2014-04-09T21:29:45.750

The -h flag did it. My Solution:

 for f in `find . -user 502`; do echo $f; chown -h <username>:admin $f; done
 – Jan Galinski  – 2014-04-09T21:48:19.570

The | xargs-way would have worked just as well, and is probably faster ;) – mtak – 2014-04-09T21:51:51.377

It did not work right away, so I used the loop to print out some debug. – Jan Galinski – 2014-04-09T21:56:48.267