1832675 Members
2953 Online
110043 Solutions
New Discussion

Help Changing UID

 
SOLVED
Go to solution
Tony Williams
Regular Advisor

Help Changing UID

Hi, I created Users for a new SAP instance before I found out that we have a standard UID strategy. The UID must contain the the SAP Instance Number. So now I need to change the UIDs, not the usernames of my SAP instance Oracle admin and SAP admin. I have read a few of the past forum posts and am confused. Is there some restriction to just changing the UID in the /etc/passwd file? What is the correct procedure for just changing the UID and not the username?
8 REPLIES 8
Pete Randall
Outstanding Contributor

Re: Help Changing UID

Tony,

The UID simply needs to be unique. You can edit the password file (carefully) with vi or vipw and manually change the UID numbers that you need to.


Pete


Pete
Peter Nikitka
Honored Contributor

Re: Help Changing UID

Hi,

consider that files already created will NOT automatically change their uids - you need a find command like this:

find DIR -user OLDid1 -print | xargs chown NEWid1

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
Dave Johnson_1
Super Advisor

Re: Help Changing UID

You should never edit the password file with vi. The correct method is to use vipw which locks the password file so no one changes there password while you are mucking it up. It also does a sanity check on root to be sure the system will still reboot once you are done messing around.
Once you manually change the UID you will need to change the owner of any files that were created by or assigned to the old UID.
Have fun
-Dave
Steven E. Protter
Exalted Contributor

Re: Help Changing UID

vipw protects you from a double edit on the file you edit. It locks it the file during the edit.

It is the preferred method of editing /etc/passwd

As a practical matter, if you are the only administtrator, there is little harm that can be done by using vi. Still, vipw is better.

Its very important that every uid be unique. Never change a uid to zero(I don't think you will).

Its always a good idea to run pwck after a /etc/passwd edit to make sure you didn't make a mistake. Also, prior to working back up the file and make the permissions on the backup very restricitve.

If you leave a copy of passwd laying around it is a hacker/crack user's dream.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
V. Nyga
Honored Contributor

Re: Help Changing UID

Hi,

you also can do it with SAM. Go to 'users' - mark one user, than under 'Actions' you have the choice 'Modify'. Sorting the list to UID, so you can check that all are unique UID's.

Regards
Volkmar
*** Say 'Thanks' with Kudos ***
Jeff Schussele
Honored Contributor

Re: Help Changing UID

Hi Tony,

usermod -u ###### login_name

where ######=new UID

Be advised that you'll have to do a find -user login_name -exec chown.......so the users' files will have proper ownership post-change.

Rgds,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Tony Williams
Regular Advisor

Re: Help Changing UID

Hi,

Thanks for all the good info, as a followup how can I see the relationship between the UID and the username on a file?
Pete Randall
Outstanding Contributor
Solution

Re: Help Changing UID

Tony,

You can use ls -n and compare it to ls -l. That will give you the uid in the -n list and the name from the -l list.


Pete


Pete