To change the user name and UID (user ID) in Linux, you can use the usermod
command with the -l
and -u
options.
Here's an example of how to use the usermod
command to change the user name and UID for a user:
usermod -l new_username -u new_uid old_username
This will change the user name from old_username
to new_username
and the UID from the old value to new_uid
.
Note that you will need to update any files or directories that are owned by the user to reflect the new user name and UID. You can use the chown
command to do this. For example:
chown -R new_username: /path/to/user/home/directory
This will recursively change the owner and group of all files and directories in the user's home directory to the new_username
user and group.