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
Red Hat 8 How to Set Up Automatic Updates for CentOS 8
Viewed 3461 times since Fri, Sep 25, 2020
ZFS: Verify/change properties of a zfs filesystem
Viewed 2379 times since Sun, Jun 3, 2018
Securing /tmp and shm partitions
Viewed 3016 times since Fri, May 15, 2020
How to deal with dmesg timestamps
Viewed 3094 times since Wed, Oct 3, 2018
Creating SWAP partition using FDISK & FALLOCATE commands
Viewed 3020 times since Thu, Jan 16, 2020
Logrotate Example for Custom Logs
Viewed 2379 times since Sun, Jan 12, 2020
Linux LVM recovery
Viewed 17429 times since Wed, Jan 23, 2019
UUIDs and Linux: Everything you ever need to know [Update]
Viewed 4803 times since Tue, Jul 17, 2018
How to use yum-cron to automatically update RHEL/CentOS Linux
Viewed 2511 times since Wed, Oct 17, 2018
Using Official Redhat DVD as repository
Viewed 10951 times since Mon, Oct 29, 2018