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
Prosty skaner portów TCP w bash
Viewed 3881 times since Thu, May 24, 2018
LVM: Extend SWAP size by adding a new Logical Volume
Viewed 3758 times since Sat, Jun 2, 2018
Method 2 – Use shell scripts How to install yum cron on a CentOS/RHEL 6.x/7.x
Viewed 4817 times since Tue, Dec 4, 2018
Split and Reassemble files
Viewed 4089 times since Mon, May 28, 2018
How setting the TZ environment variable avoids thousands of system calls
Viewed 10855 times since Mon, May 21, 2018
watchdog How to restart a process out of crontab on a Linux/Unix
Viewed 6807 times since Tue, Jul 31, 2018
RHEL: Create a local RPM repository
Viewed 12102 times since Sun, May 27, 2018
RHEL: Adding a boot entry to GRUB/GRUB2 configuration
Viewed 5597 times since Sun, May 27, 2018
RHEL: udev rules basics
Viewed 10350 times since Sat, Jun 2, 2018
10 nmap Commands Every Sysadmin Should Know
Viewed 10764 times since Wed, May 22, 2019