RHEL: How to change a USER/GROUP UID/GID and all owned files

RHEL: How to change a USER/GROUP UID/GID and all owned files

# How to change a UID/GID and all belonging files

USER=myuser
OLDUID=7773
NEWUID=7774
GROUP=mygroup
OLDGID=157
NEWGID=158



# Assign a new UID to USER. Any files which the user owns and which are located in the
# directory tree rooted at the user's home directory will have the file user ID changed
# automatically. Files outside of the user's home directory must be altered manually.

usermod -u $NEWUID $USER

# Assign a new GID to GROUP. Any files which the old group ID is the file group ID must
# have the file group ID changed manually.

groupmod -g $NEWGID $GROUP


# Manually change files with old UID

find / -user $OLDUID -exec chown -h $USER {} \;


# Manually change files with old GID

find / -group $OLDGID -exec chgrp -h $GROUP {} \;
0 (0)
Article Rating (No Votes)
Rate this article
Attachments
There are no attachments for this article.
Comments
There are no comments for this article. Be the first to post a comment.
Full Name
Email Address
Security Code Security Code
Related Articles RSS Feed
How to retrieve and change partition’s UUID Universally Unique Identifier on linux
Viewed 4291 times since Tue, Jul 17, 2018
How To Run Multiple SSH Command On Remote Machine And Exit Safely
Viewed 5606 times since Tue, Aug 6, 2019
RHEL: Services basic management - systemd
Viewed 20002 times since Sat, Jun 2, 2018
Linux 16 Useful Bandwidth Monitoring Tools to Analyze Network Usage in Linux
Viewed 18951 times since Mon, Sep 21, 2020
Lsyncd: live file syncronization across multiple Linux servers
Viewed 8096 times since Wed, Oct 31, 2018
RHEL: How to rebuild and/or patch a RPM package
Viewed 10229 times since Sat, Jun 2, 2018
Fake A Hollywood Hacker Screen in Linux Terminal linux FUN
Viewed 7831 times since Thu, Apr 18, 2019
Configuring VLAN interfaces in Linux
Viewed 7060 times since Mon, May 21, 2018
LUKS dm-crypt/Device encryption GUIDE
Viewed 3155 times since Fri, Jul 13, 2018
How to sort IP addresses in Linux
Viewed 4476 times since Sun, May 20, 2018