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 accurately determine when the system was booted
Viewed 3063 times since Wed, Oct 3, 2018
Df command in Linux not updating actual diskspace, wrong data
Viewed 3863 times since Wed, May 30, 2018
RHEL: Resize/disable /dev/shm filesystem
Viewed 17323 times since Sun, May 27, 2018
Open SSL Creating Certificate Signing Request — CSR Generation
Viewed 2723 times since Mon, Feb 18, 2019
Linux Linux Network Statistics Tools / Commands
Viewed 10745 times since Mon, Sep 21, 2020
20 Practical Examples of RPM Commands in Linux rpm
Viewed 9349 times since Mon, Feb 18, 2019
What UUIDs can do for you
Viewed 2741 times since Tue, Jul 17, 2018
Linux - How to perform I/O performance test with dd command
Viewed 7163 times since Fri, Jun 8, 2018
How to use yum-cron to automatically update RHEL/CentOS Linux
Viewed 3799 times since Wed, Oct 17, 2018
A Simple Guide to Oracle Cluster File System (OCFS2) using iSCSI on Oracle Cloud Infrastructure
Viewed 10534 times since Sat, Jun 2, 2018