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
HowTo: Find Out Hard Disk Specs / Details on Linux
Viewed 3601 times since Mon, Jan 28, 2019
RHEL: Crash kernel dumps configuration and analysis on RHEL 7
Viewed 7226 times since Sat, Jun 2, 2018
Fix rpmdb: Thread died in Berkeley DB library
Viewed 21192 times since Fri, Feb 14, 2020
O’Reilly’s CD bookshelf
Viewed 12969 times since Wed, Jun 27, 2018
Using stunnel and TinyProxy to obfuscate HTTP traffic
Viewed 7062 times since Fri, Sep 28, 2018
ubuntu How to reset lost root password on Ubuntu 16.04 Xenial Xerus Linux
Viewed 8341 times since Tue, Dec 8, 2020
Odpalenie polecenia tylko na jedną godzinę
Viewed 2908 times since Thu, May 24, 2018
RHEL: Handling SCSI disks
Viewed 12572 times since Sun, May 27, 2018
LVM: Reduce an existing Logical Volume / Filesystem
Viewed 3624 times since Sat, Jun 2, 2018
RHEL: Extending a multipath LUN
Viewed 5142 times since Sun, May 27, 2018