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
Linux - How to shutdown or reboot
Viewed 2269 times since Fri, Jun 8, 2018
How to Configure ‘FirewallD’ in RHEL/CentOS 7 and Fedora 21
Viewed 10669 times since Wed, Oct 9, 2019
RHEL: Crash kernel dumps configuration and analysis on RHEL 5
Viewed 7423 times since Sat, Jun 2, 2018
RHEL: Handling SCSI disks
Viewed 12643 times since Sun, May 27, 2018
Linux Chage Command to Set Password Aging for User
Viewed 2572 times since Tue, Sep 11, 2018
How setting the TZ environment variable avoids thousands of system calls
Viewed 10336 times since Mon, May 21, 2018
LVM: Extend an existing Volume Group by adding a new disk
Viewed 2192 times since Sat, Jun 2, 2018
How To Use Systemctl to Manage Systemd Services and Units
Viewed 7669 times since Mon, Dec 7, 2020
RHEL7: Configure automatic updates.
Viewed 1998 times since Wed, Oct 17, 2018
How to Migrate from RHEL 8 to CentOS 8
Viewed 3224 times since Fri, May 15, 2020