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 Find Large Files
Viewed 2496 times since Mon, Oct 29, 2018
List usernames instead of uids with the ps command for long usernames
Viewed 1891 times since Wed, Jul 25, 2018
How to retrieve and change partition’s UUID Universally Unique Identifier on linux
Viewed 2458 times since Tue, Jul 17, 2018
RHEL: Scan and configure new SAN (fibre channel) LUNs
Viewed 7299 times since Sun, May 27, 2018
Using etckeeper with git
Viewed 6120 times since Sun, Jun 3, 2018
HP-UX - Stunnel Configuration
Viewed 2059 times since Fri, Sep 28, 2018
LVM: Extend an existing Volume Group by adding a new disk
Viewed 1637 times since Sat, Jun 2, 2018
YUM How to use yum command on CentOS/RHEL
Viewed 6339 times since Thu, Oct 25, 2018
Deskshare TLS over Stunnel
Viewed 2426 times since Fri, Sep 28, 2018
How to encrypt a partition using LUKS?
Viewed 1481 times since Fri, Jul 13, 2018