Created
December 11, 2021 17:33
-
-
Save danielm/1714ae5f32480d43e09294832a09b293 to your computer and use it in GitHub Desktop.
Change Unix/Linux UID
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# THIS IS EXTREMLY RISKY TO RUN IF U DONT KNOW WHATS GOING ON | |
# DONT JUST COPY PASTE STUFF, READ IT, UNDERSTAND WHATS GOING SO IT WONT BREAK YOUR USER/SYSTEM | |
# | |
# put the information we need in variables | |
username=danielmorales | |
old_uid=`id -u $username` # looks up current (old) uid | |
new_uid=1000 | |
# update the user ID and group ID for $username | |
usermod -u $new_uid $username | |
groupmod -g $new_uid $username | |
# update the file ownerships | |
# NB: you cannot combine the next two chowns, or files where | |
# only the uid xor the gid matches won't be updated | |
chown -Rhc --from=$old_uid $new_uid / # change the user IDs | |
chown -Rhc --from=:$old_uid :$new_uid / # change the group IDs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment