User Tools

Site Tools


change_user_uid

Table of Contents

Change UID of User

Why

OK - it doesn't matter what you told it your name is when you first started - in a default setup your eee PC has a user called user with a uid (an identifying number) of 1000.

This is usually fine, unless you have an NFS server you want to connect to as a different user WITH A DIFFERENT UID. (For a different solution to this, do man exports on your NFS server and read about the map_static and map_daemon options. You may be able to map UID 1000 to something else on the server. These options may not be available on all NFS servers.)

In my case, my daughter has a UID of 1004 on the file server, so it makes life much easier if she has the same UID on the eee PC.

In another case, I have several USB sticks with ext3 file systems on them. It is handy to have the same uid on every machine I plug them into, so I don't have to do sudo chown user files everywhere.

How

WARNING - if you get this wrong, you may find you have to reset your eee PC to get access, and thus lose all your files.

I did this from a freshly reinstalled machine (f9 on boot). YOUR-UID is the User ID you want to use - typically 1004, 1031, something like that.

STEP 1 Pop up a terminal window with CTRL-ALT-t

STEP 2 Change the ownership of the files on your system so you can access them next time you log in :

sudo find / -uid 1000 -print0 | sudo xargs -0 chown YOUR-UID

You should do it this way instead of just changing the uid of files in /home/user, because X and KDE create some files in /tmp and /var/tmp. If they exist when you reboot, your new user id won't be able to write to them, and things will fail.

The -print0 flag to find makes it put a null byte between the names of the files it finds, instead of putting each one on a separate line, and the -0 flag to xargs makes it expect names separated by null bytes instead of white space. Together, these two things make find and xargs handle files with spaces (and other strange characters) in their names.

STEP 3 Edit the passwd file to change the UID of “user” to your desired number.

sudo nano /etc/passwd 

You need to edit the line starting “user” (probably the last line).

The fields in this file are separated by ”:”. The 3rd field is the UID. Currently it's 1000 - change it to your required UID and save the file. i.e. change

user:x:1000:1000:Joe Bloggs:/home/user:/bin/bash

to

user:x:YOUR-UID:1000:Joe Bloggs:/home/user:/bin/bash

Save the file

STEP 4 Reboot

You may get errors on the shutdown, as some programs still running under the old UID try to write to files which have had their owner changed. Things should be ok when you start again. If not, try running the chown step (Step 2) again.

Good luck.

change_user_uid.txt · Last modified: 2008/06/11 05:41 by russells