How to change group ID and user ID in Ubuntu

When working with a network file system (NFS), it is necessary, that users has the same unique user ID and group ID on all machines in order to ensure read and write privileges.

Changing user ID and group ID for a user is not as easy as it sounds. If not done correct, such changes can cause the user account to fail. If the user has encrypted files and folders, then these changes will cause the user account and associated files and folders to fail.

In this example, we want to configure an Ubuntu 9.04 workstation to match the user ID and group ID, that are used on a network file system.

We need to perform this procedure while logged in as a user, that has system administrator privileges, and, that is not the same user as the one, that need to have changes to user ID and group ID done. If no other user exist, we need to create one from

If the group for our users does not exist, we create it at this point.

groupadd -g 1001 users

If the group for our users exist with a wrong ID, then we change it.

groupmod users -g 1001

We change the user ID and the group ID for users. Files in the user home will have their ownership updated automatically. In our example, the group ID and the user ID for Ann is changed to match the network file system and the operating system is rebooted.

usermod -g users -G adm,dialout,cdrom,floppy,audio,plugdev,lpadmin,admin,sambashare -u 1009 ann

reboot

Confirm, that users and groups was changed as expected by inspecting the files passwd and group in /etc.

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.


Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>