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
Open SSL HowTo: Decode SSL Certificate
Viewed 5828 times since Mon, Feb 18, 2019
Tcpdump Examples Linux
Viewed 5575 times since Fri, Nov 16, 2018
RHEL: Multipathing basics
Viewed 8153 times since Sat, Jun 2, 2018
RHEL: Route network packets to go out via the same interface they came in
Viewed 2663 times since Sat, Jun 2, 2018
Linux LVM recovery
Viewed 17073 times since Wed, Jan 23, 2019
How To: Create Self-Signed Certificate – OpenSSL
Viewed 2675 times since Mon, Feb 18, 2019
How to configure an SSH proxy server with Squid
Viewed 2629 times since Sun, Dec 6, 2020
tcpdump usage examples
Viewed 2043 times since Fri, Jul 27, 2018
Get UUID of Hard Disks [Update]
Viewed 1925 times since Tue, Jul 17, 2018
ZPOOL: Detach a submirror from a mirrored zpool
Viewed 2311 times since Sun, Jun 3, 2018