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
OpenSSL – sprawdzanie czy klucz pasuje do certyfikatu
Viewed 2614 times since Thu, May 24, 2018
How To Add Swap Space on Ubuntu 16.04
Viewed 2271 times since Fri, Jun 8, 2018
How to mount software RAID1 member using mdadm
Viewed 2956 times since Wed, Oct 3, 2018
RHEL: udev rules basics
Viewed 8384 times since Sat, Jun 2, 2018
How to disable SSH cipher/ MAC algorithms for Linux and Unix
Viewed 45871 times since Fri, Aug 21, 2020
ZPOOL: Detach a submirror from a mirrored zpool
Viewed 2592 times since Sun, Jun 3, 2018
Cron YUM How to use yum-cron to automatically update RHEL/CentOS Linux
Viewed 2368 times since Fri, Oct 26, 2018
Tips to Solve Linux & Unix Systems Hard Disk Problems
Viewed 4034 times since Fri, May 15, 2020
how to list all hard disks in linux from command line
Viewed 3356 times since Mon, Jan 28, 2019
Use inotify-tools on CentOS 7 or RHEL 7 to watch files and directories for events
Viewed 13946 times since Fri, Jul 27, 2018