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
linux ssh How to Hide the OpenSSH Version Details when Telnet to Port 22
Viewed 5748 times since Wed, Apr 22, 2020
RHEL: Allowing users to ’su’ to "root" / Allowing ’root’ to login directly to the system using ’ssh’
Viewed 3116 times since Sat, Jun 2, 2018
Linux PAM configuration that allows or deny login via the sshd server
Viewed 2206 times since Wed, Oct 3, 2018
How To Ping Specific Port Number
Viewed 4783 times since Mon, Jun 1, 2020
stunnel: Authentication
Viewed 9361 times since Fri, Sep 28, 2018
How to sort IP addresses in Linux
Viewed 3908 times since Sun, May 20, 2018
Prosty skaner portów TCP w bash
Viewed 3517 times since Thu, May 24, 2018
Linux: how to monitor the nofile limit
Viewed 10963 times since Wed, Jul 25, 2018
Moving SSL Certificate from IIS to Apache
Viewed 2211 times since Mon, Feb 18, 2019
red hat 7 tmpfiles service
Viewed 2055 times since Thu, Oct 11, 2018