How do I change a UID?

QuestionsQuestions8 SkillsProYour First Linux LabOct, 20 2025
0115

To change a user's UID (User Identifier) in Linux, you can use the usermod command. Here’s how to do it:

Syntax:

sudo usermod -u NEW_UID USERNAME

Steps:

  1. Open Terminal.
  2. Run the command:
    Replace NEW_UID with the desired UID and USERNAME with the name of the user whose UID you want to change.

Example:

sudo usermod -u 6000 labex

Important Notes:

  • File Ownership: After changing the UID, you may need to update the ownership of files owned by the old UID. You can do this with:
    sudo find / -user OLD_UID -exec chown -h NEW_UID {} \;
  • Logout/Login: The user may need to log out and back in for the changes to take effect.

Make sure to back up important data before making changes to user accounts. If you have further questions, feel free to ask!

0 Comments

no data
Be the first to share your comment!