1. Back up the user's original files from user's home directory to a safer place, like the
/tmp/ directory,
/root/, or, probably safer still, a USB thumb drive.
2. Delete the user with uid = 1003, and it's private user group, which will probably have the same group id as user's user id.
3. If there another user account with uid = 1001, delete it and its group in similar fashion.
4. Create a new user and private group with uid = 1001 and gid = 1001.
5. Add the new user to the desired public groups, for example, group names wheel, video, and operator.
6. Restore the user's original files and directories to its new home directory.
Reference:
pw()
Hint:
Code:
# cd /home; tar -czpf user.tgz user; mv user.tgz /root/ #--- back up offending user account's files and directories
# pw userdel -n user -u 1003 -r #--- delete the offending user account
# pw groupdel -n user -g 1003 #--- delete offending user account's group account
# pw userdel -n SomeOtherUserName -u 1001 #--- Only if found, delete any other user who might have uid = 1001.
# pw groupadd -n user -g 1001 #--- add back the group account, this time with the desired group id
# pw useradd -n user -u 1001 -c "Comment about user" -d /home/user -g user -m -s /bin/sh #--- add user account with same id no.
# pw groupmod wheel -m user #--- add user to wheel group
# pw groupmod video -m user #--- add user to video group
# pw groupmod operator -m user #--- add user to operator group
# cp /root/user.tgz /home/ ; rm -rf user ; tar -xzpf user.tgz #--- restore original files and directories to new user account
I haven't tested these commands lately, some of it may be a bit of overkill, and there are undoubtedly more elegant ways to go about this, but hopefully it will help you get back on the right track. It might only be necessary to add user to its private group and the wheel account. This is just a rough sledgehammer approach which probably doesn't check for everything which might possibly go wrong. Be careful. If I were doing this, I would test each command on some throw-away accounts before trying them out with the actual files and directories you're dealing with. Please don't put too much faith in me, my mouth is not a prayer book and I'm always in too much of a hurry. Remember, I'm just some anonymous and unaccountable dude on the internet who's trying to be helpful. If the damage is already very extensive, it may be faster just to reinstall and start from scratch with a clean system.