How to change UID?

QuestionsQuestions8 SkillsProYour First Linux LabSep, 28 2025
0163

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: Access your terminal.
  2. Run the Command: Replace NEW_UID with the desired UID and USERNAME with the target user's name.
    sudo usermod -u 6000 labex
  3. Update File Ownership: After changing the UID, you may need to update the ownership of the user's files to reflect the new UID:
    sudo find / -user OLD_UID -exec chown -h NEW_UID {} \;

Important Notes:

  • Backup: Always back up important data before making changes.
  • Logout/Login: The user may need to log out and back in for changes to take effect.
  • Permissions: Ensure you have the necessary permissions (usually root) to change UIDs.

If you have more questions or need further assistance, feel free to ask!

0 Comments

no data
Be the first to share your comment!