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


# 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
There are no attachments for this article.
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
Linux - How to unlock and reset user’s account
Viewed 2142 times since Fri, Jun 8, 2018
Testing TLS/SSL encryption
Viewed 12252 times since Thu, Jan 16, 2020
Linux RedHat How To Create An RPM Package
Viewed 1024 times since Sun, Jan 9, 2022
How to create a Systemd service in Linux
Viewed 1861 times since Mon, Dec 7, 2020
ZPOOL: Detach a submirror from a mirrored zpool
Viewed 2018 times since Sun, Jun 3, 2018
systemctl Use systemd to Start a Linux Service at Boot
Viewed 4577 times since Mon, Dec 7, 2020
Index » Community Contributions » System encryption using LUKS and GPG encrypted keys for arch linux
Viewed 1591 times since Fri, Jul 13, 2018
6 rsync Examples to Exclude Multiple Files and Directories using exclude-from
Viewed 3498 times since Wed, Oct 31, 2018
Linux / UNIX: Run Command a Number of Times In a Row
Viewed 13983 times since Tue, Aug 6, 2019
Linux – Securing your important files with XFS extendend attributes
Viewed 7005 times since Wed, Jul 25, 2018