Ashoori Group

Ashoori Group | Homepage

  • Increase font size
  • Default font size
  • Decrease font size

Changing User ID (UID)

Note: this is not a simple thing to do. If you're concerned, ask for help. It's much easier just to get the UID and GID to be the same as on electron when creating the new account; with add-user, use the --with-uid and --with-gid settings. This document assumes you're comfortable editing files with a text editor.

Run id on electron and the machine you're working on, and write down your user ID and group ID (the first one) on electron and on the machine you're working on (they're probably the same). We'll refer to your user id as a UID, and your group ID as a GID.

You'll need to be logged in as root on the machine you're going to work on. Hit Alt-F1 or Control-Alt-F1 to get a text console, and log in directly as root. Ideally, you should not be logged in as yourself at all.

Edit /etc/passwd Find the line that starts with your user name; for example, for me, it reads

odie:x:1000:1000:odie,13-2045,x38497,617-945-0308:/home/odie:/usr/bin/zsh

The third and fourth numbers are your UID and group ID respectively. Change them to match your UID and GID on electron.

Edit /etc/group Find the line that starts with your user name; for example, for me, it reads

odie:x:1000:

Change the number to match your GID on electron.

Finally, you need to change the ownership of all your files to reflect the new UID and GID. Run

find / -xdev -user [old-uid] -exec chown [new-uid] {} \;

Here, [old-uid] is your old UID on this machine, and [new-uid] is your UID on electron. This may take a while.

find / -xdev -group [old-gid] -exec chgrp [new-uid] {} \;

Here, [old-gid] is your old GID on this machine, and [new-gid] is your GID on electron. This may take a while.

Finally, reboot your machine. (You don't have to do this, but it's important that you don't leave yourself logged into it after this.

Make sure you can still edit your own files, and that id shows a UID and GID that match the values on electron.