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
YUM How to use yum command on CentOS/RHEL
Viewed 8555 times since Thu, Oct 25, 2018
RHCS6: ’fencing’ basics
Viewed 3235 times since Sun, Jun 3, 2018
Linux Screen
Viewed 2868 times since Sat, Jun 2, 2018
www.unixarena.com
Viewed 3142 times since Fri, Jul 27, 2018
Expand or grow a file system on a Linux VMWare VM without downtime
Viewed 12557 times since Fri, Jul 27, 2018
systemctl Use systemd to Start a Linux Service at Boot
Viewed 6945 times since Mon, Dec 7, 2020
Linux RAID Mdadm Cheat Sheet
Viewed 6650 times since Fri, May 15, 2020
Linux File Systems (mkfs, mount, fstab) ext4
Viewed 4202 times since Sat, Jun 2, 2018
Understanding logrotate utility part 1
Viewed 2610 times since Fri, Nov 30, 2018
12 Linux Rsync Options in Linux Explained
Viewed 13240 times since Wed, Oct 31, 2018