script for creating aix user | Unix Linux Forums | AIX

  Go Back    


AIX AIX is IBM's industry-leading UNIX operating system that meets the demands of applications that businesses rely upon in today's marketplace.

script for creating aix user

AIX


Tags
linux

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 04-08-2008
itik itik is offline
Registered User
 
Join Date: Oct 2007
Last Activity: 12 December 2013, 10:00 PM EST
Location: Toronto, Ontario
Posts: 383
Thanks: 0
Thanked 2 Times in 2 Posts
script for creating aix user

Hi Guys,

I want to create user with a script:

user name, user id, primary group, group set, home directory, initial program, password, user information, another user can SU to user. And all the rest is the default.

Does anyone already have the script for this? Can you please share it with me and the rest on the group.

Thanks in advance,
itik
Sponsored Links
    #2  
Old 04-09-2008
Yac Yac is offline
Registered User
 
Join Date: Sep 2007
Last Activity: 16 May 2012, 2:24 AM EDT
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Hi,
Enter in command line: smitty user, choose Add a User. Then enter necessary information ie. name, groups etc. Finally press F6 and you'll get the complete script.

Greets,
Yac.
Sponsored Links
    #3  
Old 04-09-2008
prichard prichard is offline
Registered User
 
Join Date: Mar 2008
Last Activity: 30 June 2010, 4:51 PM EDT
Posts: 32
Thanks: 1
Thanked 0 Times in 0 Posts
If you wish to automate user creation, first, as Yac suggests, create a user with "smitty user". Then copy the relevant parts of the smit.script and make them work for your needs.
    #4  
Old 04-10-2008
bakunin bakunin is offline Forum Staff  
Bughunter Extraordinaire
 
Join Date: May 2005
Last Activity: 25 October 2014, 3:34 PM EDT
Location: In the leftmost byte of /dev/kmem
Posts: 4,286
Thanks: 45
Thanked 824 Times in 651 Posts
@prichard & Yac: Sorry, but i do not think it is that simple. To be useful such a script will have to deal with several error conditions. What you get out of "smitty user" is simply a wrapper for the "mkuser" command.

For instance assume the following situation: The script is called to create a user "foo" with UID 42. The following errors now could occur and should be reported back with different error levels from the script:

- a user "foo" exists already with uid=42 (=the user exists)

- a user "foo" exists with uid=43 (username already taken)

- a user "bar" exists with uid=42 (userid already taken)

- a user "foo" with uid=43 and a user "bar" with uid=42 exist already

How about other errors, like (unsorted): the script not being called by root, unable to create the home directory, the username is not a legal one, the uid is not legal, ..... (and i don't even mention the errors connected with the group memberships)

True, the last step would be to call "mkuser" and be done, but the necessary checks before look like an interesting programming task.

I hope this helps.

bakunin
Sponsored Links
    #5  
Old 04-10-2008
prichard prichard is offline
Registered User
 
Join Date: Mar 2008
Last Activity: 30 June 2010, 4:51 PM EDT
Posts: 32
Thanks: 1
Thanked 0 Times in 0 Posts
I did not say it would be simple. I just said that one can make the smit.script work for their needs. It is a starting point for automation. Until one understands what to check for one should stay with "smitty user" since it checks all that stuff for you. Very powerful.
Sponsored Links
    #6  
Old 04-10-2008
itik itik is offline
Registered User
 
Join Date: Oct 2007
Last Activity: 12 December 2013, 10:00 PM EST
Location: Toronto, Ontario
Posts: 383
Thanks: 0
Thanked 2 Times in 2 Posts
Thank you for all your input.

I guess, I would be the first one to create the script. I'll share it when I'm done. It's hard adding hundreds of user manually or smitty, I really need to do it in a script.

Is there a danger of editing manually all these files?

/usr/lib/security/mkuser.default Contains the default values for new users.
/etc/passwd Contains the basic attributes of users.
/etc/security/user Contains the extended attributes of users.
/etc/security/user.roles Contains the administrative role attributes of users.
/etc/security/passwd Contains password information.
/etc/security/limits Defines resource quotas and limits for each user.
/etc/security/environ Contains the environment attributes of users.
/etc/group Contains the basic attributes of groups.
/etc/security/group Contains the extended attributes of groups.
/etc/security/.ids Contains standard and administrative user IDs and group IDs.

Last edited by itik; 04-10-2008 at 12:08 PM..
Sponsored Links
    #7  
Old 04-10-2008
bakunin bakunin is offline Forum Staff  
Bughunter Extraordinaire
 
Join Date: May 2005
Last Activity: 25 October 2014, 3:34 PM EDT
Location: In the leftmost byte of /dev/kmem
Posts: 4,286
Thanks: 45
Thanked 824 Times in 651 Posts
Quote:
Originally Posted by itik View Post
Is there a danger of editing manually all these files?
No, there is not, but IMHO it ist still preferable to do it with the AIX commands, namely mkuser.

I already attempted what you do now and can provide you with a script function to check some of the mentioned conditions. I will put it in here later this afternoon.

bakunin
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Creating oracle user and giving him grants using shell script Deepakjha Shell Programming and Scripting 4 10-10-2009 02:49 PM
help needed with creating challenging bash script with creating directories I-1 Shell Programming and Scripting 7 04-29-2009 05:33 AM
Limiting length of user in while creating user Satya Mishra AIX 2 04-15-2005 02:40 AM
creating a new user rocker40 UNIX for Dummies Questions & Answers 7 05-04-2004 04:33 PM
creating a new user Newbie4ever UNIX for Dummies Questions & Answers 3 07-27-2002 09:51 AM



All times are GMT -4. The time now is 06:49 PM.