How to Change a USER and GROUP ID on Linux For All Owned Files

To change the user and group ID of all files owned by a specific user on Linux, you can use the chown command with the -R (recursive) option. Here’s an example:

  1. Open a terminal window.
  2. Run the following command to change the user ID (UID) of the user olduser to newuser:
sudo chown -R newuser: olduser /home/olduser

Note that in this example, the user’s home directory is located at /home/olduser. Replace this with the actual path to the user’s home directory.

  1. If you also want to change the group ID (GID) of the user, use the following command:
sudo chown -R newuser:newgroup /home/olduser

Note that newgroup is the name of the new group.

  1. Verify that the ownership of all files has been successfully changed by running the following command:
ls -l /home/olduser

You should see that the user and group columns in the output show newuser and newgroup, respectively.

Leave a Comment