More SUMMARY: Change UID

From: Feng Qiu (
Date: Thu Jan 02 1997 - 12:15:49 CST

Thanks for all answers!!

from: larry d. clark" <>

If you are root, change /etc/passwd, then cd into the directory
where the $HOME is and issue chown -R user_name $HOME.

from: (Steve Ozoa)

You'll also have to fix the ownership of all their files

from: (Michael Sullivan)

Besides /etc/passwd, you will need to change /etc/shadow, and you will
need to change ownership of all the user's directories and files, not
just those under his home directory, but any others that may be
scattered around the file systems, such as /var/mail/user.

from: "K.Ravi" <>

Yes, you have to modify /etc/passwd. Edit it manually or use 'usermod'.
But be
sure to do a 'chown' for all files owned by the user. (cd to user's home
directory, run 'chown -R <newuid> *' . If the user's files are spread in
different places, you might have to do something like this:
# find / -user <olduid> -print |xargs chown <newuid> )

from: Cagri Yucel <>

Change password file. But the files owned by this user will remain
the old UID. This probably will be displayed as a number, make a
chown -R new_uid users_home to solve this problem.

from: si jianwei <>

You can do this job if you have root account.
Please try it .
First you should change to root user. Next, use "usermod" command. For
% su -
# usermod -u 9999 usera
# cd ~/usera; cd ..
# chown -R usera usera

Of course, you can edit /etc/passwd file to change user's id.
But , be warned the user's home directory must be changed with "chown"

from: Tom Powers <>

On the off hand chance you haven't already gotten a hundred replies
to this, here's my suggestion.

Use the command:
        usermod -u NEWUID LOGIN
then run a find to change the ownership
        find / -user OLDUID -print -exec chown NEWUID {} \;

I'm in the process of syncronising a few dozen machines, all of which
have the same users but different UID numbering schemes, so I'm using
this a lot

from: (Frank Pardo)


also, chown for all files owned by that user

from: "Matthew Stier" <Matthew.Stier@MCI.Com>

Passwd entry, and the ownership of any files originally owned by the old
UID to the new UID.

from: (Todd Boss)

well you'll also have to chown every file the user owns back to
his/her'll find them all to be the old userid.
With a normal user this is pretty easy; all their files should
be in their home directory. With a user like sybase or oracle, and
with sql servers running, it can be much more complex.

I suggest performing a find from root looking for the old uid and
changing it;

find / -user <old uid> -exec chown <new user> {} \;

should do the trick

from: (Jerry Springer)

Changing the UID in the password file will change the UID of the user
the next time he/she logs in.
What it will not change is the ownership of any file that was owned by
users previous UID.
Files/Directories are really owned by UIDs, NOT usernames. The
doing an ls converts the UID to a username for human convenience.

What you will need to do, and it can be done before or after the
password file
change, is to find all files owned by the UID that you are changing and
the ownership to the new UID.

This can be done with a simple find command.
Run this as root and substitute the numberic UID's where I use
OUID (for the original UID) and NUID (for the new UID)

find / -user OUID -exec /usr/bin/chown NUID {} ";"

what this does is search all files starting from the root directory
looking for files owned by OUID, it then runs the command chown with the
The {} indicates to the find command to use any filenames found to meet
the criteria (ie owned by OUID) as a parameter to the chown command. The
ends the find command but due to the fact that ; means something to the
you must quote it to keep the shell from interpretting it before the
command can.

from: Rasana Atreya <>

Do a man on usermod.


original message:
> Hello, Happy New Year!!
> If I want change a User's UID, what should I change, passwd file,
> anything else? SPARCStation 5 with solaris2.5.1.
> Thanks!!

This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:11:42 CDT