• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to assign password for a user in shell script

 
pavan bellari
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is to create a new user and assign a password for that user from the shell script instead of at prompt.
i have create a file using vi editor
and i have typed
useradd xyz
passwd xyz pqr
and when i run the shell by giving bash file name, the new user is created but the password is not assigned. it is treating pqr is also a username
please tell me how to assign password for a user from the shell script
[ October 16, 2003: Message edited by: pavan bellari ]
 
Richard Klein
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
You can generate a password with the useradd command :
useradd [-c comment] [-d home_dir]
[-e expire_date] [-f inactive_time]
[-g initial_group] [-G group[,...]]
[-m [-k skeleton_dir] | -M] [-p passwd]
[-s shell] [-u uid [ -o]] [-n] [-r] login
Richard
 
pavan bellari
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello Mr Richard Klein
Thanks for ur quick reply.
I had already tried what u said useradd -p option. no error is shown in that
but when we login with the user created with useradd -p it is not allowing to login.
but when we entered as root and tried to create useradd with the username above it is showing that user already exists
that means though we give the command useradd -p it is creating the new user but not assigning the password
pls reply this soon
thanks in advance
 
Richard Klein
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could try the following:
useradd $account_name
echo $account_pwd | passwd --stdin $account_name
Regards
Richard
 
pavan bellari
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mr Richard Klien
It is working well.
U have done a great job to me. It is very much worth for me. I am in the mid of project . If any doubts can i contact u. pls give me ur mail id
Thank u very much
one more doubt. If possible pls clarify
I am connecting Windows and Linux machine thru Java RMI. and my server files are in Linux Server. when I connect Linux machine(144.16.75.124) thru Java on Windows It is showing error:
java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is:
java.net.ConnectException: Connection refused: no further information
although I have given the ip-address of the linux machine(here it is 144.16.75.124). The error is Connection refused to host: 127.0.0.1
and I haven't mentioned 127.0.0.1 or localhost any where in the program
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic