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
awk printf
Viewed 11455 times since Wed, Aug 19, 2020
Szybkie sprawdzenie zewnętrznego adresu IP i hosta
Viewed 1765 times since Thu, May 24, 2018
LVM: Create a new Volume Group
Viewed 1027 times since Sat, Jun 2, 2018
RHCS6: Extend an existing Logical Volume / GFS2 filesystem
Viewed 1643 times since Sun, Jun 3, 2018
OpenSSL: Check If Private Key Matches SSL Certificate & CSR
Viewed 1260 times since Mon, Feb 18, 2019
10 Linux rsync Examples to Exclude Files/Directories
Viewed 9524 times since Wed, Oct 31, 2018
ZFS: Snapshots and clones on zfs filesystems
Viewed 1814 times since Sun, Jun 3, 2018
RHEL: Forgotten ’root’ password / using single-user to gain access
Viewed 4694 times since Sat, Jun 2, 2018
PROCESSOR AND MEMORY INFORMATION
Viewed 4260 times since Sat, Jun 2, 2018
Red Hat ADDING SWAP SPACE
Viewed 1023 times since Fri, Jun 8, 2018