/usr/sbin/usermod -u 12345 joeuser
Now you have to change all joeuser's files to the new UID. Remember that ufs and ext* file systems store all ownerships with the UID, not the userid string.
/usr/bin/find / -user 701 -print | xargs -t chown joeuser
This will find all files with the ownership UID of 701 and reset to joeuser's new UID.

6 comments:
Because some files in the file system are containing spaces, I think
/usr/bin/find / -user 701 -exec chown joeuser {} \;
is a better command
/usr/bin/find / -user 701 -exec chown joeuser {} \;
is killer as it changes permisison on call files
Hi guys, I0'm newbie to Linux, and I think I messed up a little on server. I was cleaning old users and decided to organize current ones. I've edit passwd erase all users and then useradd all. This messed up UID. Any suggestion? I have now users, on groups that I didn't touch, that can't have proper permissions.
Hope you can help!
I have backup from old Group,passwd and shadow files
Regards,
JE
Regarding the whitespace problem: this would be the best solution
/usr/bin/find / -uid 701 -print0 | xargs -0 chown -v webmaster.webmaster
The GNU xargs (used on Linux) has a -0 (zero) option; this means the pathnames it reads are separated by NUL characters instead of whitespace
JE, you need to recover from your backup /etc/passwd, /etc/shadow and /etc/group. Then run pwck (password check) and check the consistency of your user database. Fix any issues. Then and only then, delete unused user accounts with the userdel account.
It is never a good idea to edit the files themselves. Yes I have done it, we all do, but it's not the best way.
"Then and only then, delete unused user accounts with the userdel command."
Post a Comment