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
LVM: Extend an existing Volume Group by adding a new disk
Viewed 1981 times since Sat, Jun 2, 2018
RHEL: Services basic management - systemd
Viewed 18522 times since Sat, Jun 2, 2018
12 Tcpdump Commands – A Network Sniffer Tool
Viewed 8707 times since Fri, Jul 27, 2018
HowTo: The Ultimate Logrotate Command Tutorial with 10 Examples
Viewed 5035 times since Fri, Nov 30, 2018
RHCS6: Mirror/unmirror a GFS2 volume
Viewed 5147 times since Sun, Jun 3, 2018
FIO (Flexible I/O) – a benchmark tool for any operating system
Viewed 19313 times since Wed, Jul 25, 2018
linux manual tools
Viewed 2709 times since Fri, Sep 28, 2018
Learn how to align an SSD on Linux
Viewed 12270 times since Fri, May 15, 2020
LVM: Create a new Volume Group
Viewed 1998 times since Sat, Jun 2, 2018
How to sort IP addresses in Linux
Viewed 3479 times since Sun, May 20, 2018