Sunday, January 2, 2011

Changing the user id of an existing user

There is an existing user Adam with user id 1000 that you want to change to user id 2345.
Adam is the only user on the system and is an admin, of course. Adam also has an encrypted home directory.

1) Log in as Adam.
2) Create a new admin user, say call Newsome.
3) Log out as Adam and log in as Newsome. Ensure that "sudo id" succeeds as Newsome in case you mess something up with Adam's login
4) Run System -> Administration -> Users and Groups
5) Choose Adam, then Advanced Settings. In the Advanced User Settings window choose "Advanced" and then change the user id.
6) Hit "OK" and then "Close" on the User Settings tab.
7) Run "grep Adam /etc/passwd" and verify the new user id is 2345.
8) Run "ls -ln /home/Adam" and verify the owner id is 2345.
9) In a terminal go to and run "sudo chown Adam /home/.ecryptfs/Adam"
10) In a terminal, login as Adam and verify that all the files in the home directory exist.

Ubuntu note: Normal user start at 1000. Anything below that is considered reserved, but you are free to use those IDs. On the login screen, if your ID is below 1000, you'll have to choose "Other user" (or something like that) and enter your username, which is arguable slightly more secure but more annoying.