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


# 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
There are no attachments for this article.
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
ZPOOL: Grow a zpool by adding new device(s)
Viewed 4035 times since Sun, Jun 3, 2018
18 Quick ‘lsof’ command examples for Linux Geeks
Viewed 8493 times since Sun, Jun 30, 2019
UUIDs and Linux: Everything you ever need to know [Update]
Viewed 3646 times since Tue, Jul 17, 2018
SSH: Execute Remote Command or Script – Linux
Viewed 984 times since Mon, Feb 18, 2019
LUKS dm-crypt/Device encryption GUIDE
Viewed 989 times since Fri, Jul 13, 2018
Linux - How to monitor CPU usage
Viewed 4609 times since Fri, Jun 8, 2018
How to Configure ‘FirewallD’ in RHEL/CentOS 7 and Fedora 21
Viewed 8328 times since Wed, Oct 9, 2019
15 Linux Yum Command Examples – Install, Uninstall, Update Packages
Viewed 1756 times since Thu, Oct 25, 2018
Linux How to reset a root password on Fedora
Viewed 630 times since Sun, Dec 6, 2020
Cron YUM How to use yum-cron to automatically update RHEL/CentOS Linux
Viewed 1082 times since Fri, Oct 26, 2018