1752772 Members
5050 Online
108789 Solutions
New Discussion юеВ

How to recreate user1

 
SOLVED
Go to solution
Joshua Goi
Frequent Advisor

How to recreate user1

Hi,

I have accidentally removed my user1. Is there any way to recreate that user account with it's original UID?

Thanks!
8 REPLIES 8
Stephen Keane
Honored Contributor

Re: How to recreate user1

If you know what the original UID was, then run SAM and change the UID it puts up to the one you want.
Pete Randall
Outstanding Contributor

Re: How to recreate user1

Joshua,

If you know what the original UID was (hint: you can check their home directory with "ll"), you can just recreate the user (I assume you must be using SAM), then edit /etc/passwd and change the UID to match.


Pete

Pete
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: How to recreate user1

Yes, simply add the user again either in SAM or via the useradd command. If SAM does not allow you to override the UID then simply add the user; accept whatever UID it assigns; and then usermod -u olduid user1 to assign the original UID. Man usermod for details.
If it ain't broke, I can fix that.
Joshua Goi
Frequent Advisor

Re: How to recreate user1

It doesn't work. The orginal UID is apparently reserved even though it no longer tied to any account.
Joshua Goi
Frequent Advisor

Re: How to recreate user1

Ooops my last reply is for Stephen Keane.
Stephen Keane
Honored Contributor

Re: How to recreate user1

Worth a try though. I'd go with the vineheads' suggestions.
Bill Hassell
Honored Contributor

Re: How to recreate user1

Did you simply remove the entry in /etc/passwd? If the files in the user's old HOME directory are still there, use ll to list the contents. Since the user was removed, the owner will now be a number (ll uses the passwd file to translate UID into a username). Then simply add a line with the password information. A quick way is to duplicate the last line, then change the last line to user1, the user1 UID, home directory, etc. If this is a Trusted system, you'll need to use SAM.

If you used SAM to remove user1 and you said to remove all the files in the home directory, you'll need to restore the files after recreating user1.


Bill Hassell, sysadmin
Joshua Goi
Frequent Advisor

Re: How to recreate user1

Clay's solution works! Thanks guys!