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
Epoch & Unix Timestamp Conversion Tools
Viewed 14007 times since Fri, Jun 22, 2018
WatchDog watchdog.sh script for checking server running
Viewed 1773 times since Tue, Jul 31, 2018
Linux Proxy Server Settings – Set Proxy For Command Line
Viewed 481 times since Mon, Feb 18, 2019
Top 10 darmowych i publicznych serwerów DNS
Viewed 837 times since Tue, May 22, 2018
How To Run Multiple SSH Command On Remote Machine And Exit Safely
Viewed 501 times since Tue, Aug 6, 2019
UUIDs and Linux: Everything you ever need to know [Update]
Viewed 486 times since Tue, Jul 17, 2018
KONTO SFTP Z CHROOTEM Z UŻYCIEM OPENSSH-SERVER NA CENTOS/RHEL6
Viewed 402 times since Fri, Nov 30, 2018
YUM How to use yum command on CentOS/RHEL
Viewed 2066 times since Thu, Oct 25, 2018
RHEL: Rename a network interface on RHEL 7
Viewed 2016 times since Sat, Jun 2, 2018
Open SSL HowTo: Decode SSL Certificate
Viewed 482 times since Mon, Feb 18, 2019