Bash shell script for user creation in solaris


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Bash shell script for user creation in solaris
# 1  
Old 07-29-2012
Bash shell script for user creation in solaris

Hi All,

I am new to shell scripting and have a task which need to be completed ASAP.
I have searched all the forum and couln't find excat script which could run on solaris.can someone give me the fully working script for below.

Bash shell script to create user account with paraments as below.
Code:
useradd -c "${FNAME} ${LNAME}" -d ${HOMEDIR}/${USERNAME} -m -g ${PRIGROUP} -s ${USERSHELL} ${USERNAME} > /dev/null \
        || exit 1

user should be added to /etc/passwd and I am wondering what could be the command to add password to /etc/shadow, if possible please include that in the script.

If the user already exits then exit from the script otherwise add user.

Thanks in Advance

Last edited by Franklin52; 07-30-2012 at 08:51 AM.. Reason: Please use code tags for data and code samples
# 2  
Old 08-02-2012
That command will add them to /etc/shadow, but they will have no password assigned (ie cannot log in). Typically there's no easy way to script password changes as the command is interactive, but you can play round with echo'ing the desired password into "passwd ${USERNAME}" or setting the password manually once on some box, reading it out of the shadow file, then having your script do a sed command to replace "^${USERNAME}:*LK*:" with "${USERNAME}:${ENCRYPTEDPASSWORD}:".
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script for user account Creation

Hi Folks, I had a request to create the user request. Between, I just write a script a create, Update Geos, and update the password. My script as below: The error message, what I am getting is all the users are updated with the same Goes value.. #!/bin/bash for i in `cat users.txt`;do... (2 Replies)
Discussion started by: gsiva
2 Replies

2. Windows & DOS: Issues & Discussions

Problems With User Creation Script

Hello everyone, I've been attempting to make a program which creates user accounts from a file which contains the usernames required. It also checks if the directory of the username exists in the C:\Users directory and then is going to give the option to delete the directory, or rename it, this... (1 Reply)
Discussion started by: charlieabee
1 Replies

3. UNIX for Advanced & Expert Users

Can we Automate the User creation and setting password through a script in solaris 10

Hi, I am using Solaris 10 OS and Bash shell.Is there any way can we automate User creation and setting passwords through a script or any freeware tool. Advance thanks for your response. (1 Reply)
Discussion started by: muraliinfy04
1 Replies

4. Shell Programming and Scripting

Bash script to Automate the Virtual Host creation process!!

Hi all, This is my sample code in /etc/httpd/conf.d/applications.conf file currently we are creating subdomain mannually for every new subdomain. I want to automate this process througs bash script , how its possible. <VirtualHost *:80> ServerName google.com ServerAlias google.com... (5 Replies)
Discussion started by: anishkumarv
5 Replies

5. Shell Programming and Scripting

User creation script

Hi Gems.. I am working out on project of creating a mass user on 100 server. Please help me with script where i can create an user id of new 80 user using shell script Thanks in advance. Indrajit Bhagat (1 Reply)
Discussion started by: indrajit_renu
1 Replies

6. Solaris

Creation Date of Solaris User

Hi, I am using Solaris 10. How could I find when a solaris user was created? thanks and regards (4 Replies)
Discussion started by: fahdmirza
4 Replies

7. Shell Programming and Scripting

Help in Shell scripting to modify the User Creation script in oracle database.

Hi, I have several users to create on my test Oracle database taking the scripts from the Production Oracle database. I have a separate text file where I have user-id and passwords maintained. I need help in writing a shell script to go thru the user creation scripts and replace VALUES... (1 Reply)
Discussion started by: rparavastu
1 Replies

8. Solaris

User Creation in Sun Solaris

Hi, I want to create a user who has right to change only root user password, (1 Reply)
Discussion started by: manoj.solaris
1 Replies

9. UNIX for Dummies Questions & Answers

Solaris 9 NIS user creation issue

Helloo to all... what is the correct way to assign a password to a new NIS user on a NIS master server? When I the following: useradd -s /bin/bash -d /export/home/username -m username The user get created fine but when I try to assign a password I get: #passwd username... (0 Replies)
Discussion started by: GLJ@USC
0 Replies

10. Shell Programming and Scripting

user creation using shell script for JSP

hello friends, I have problem. We want to create user from jsp(browser based) on our linux server. How we can do that ? or How do we create a user with shell programming by taking arguments and checking with the existing users and if the user exist it should display the message the user exists... (1 Reply)
Discussion started by: jarkvarma
1 Replies
Login or Register to Ask a Question