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:
- Open a terminal window.
- Run the following command to change the user ID (UID) of the user
olduser
tonewuser
:
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.
- 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.
- 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.