LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-28-2003, 11:26 AM   #1
Swift&Smart
Member
 
Registered: Jan 2003
Location: Hong Kong,China
Distribution: Slackware,OpenSUSE
Posts: 472

Rep: Reputation: 30
Add user problem


What's up!Everyone.

My question is that how can I add a user and set his/her password in one command line on Linux.I've tried -p option but it ain't work.Is that password being encrypted??

Any help is appreciated.
 
Old 09-28-2003, 11:47 AM   #2
iceman47
Senior Member
 
Registered: Oct 2002
Location: Belgium
Distribution: Debian, Free/OpenBSD
Posts: 1,123

Rep: Reputation: 47
Code:
adduser <name>; echo "<passwd>" | passwd <name> --stdin
 
Old 09-29-2003, 10:34 AM   #3
Swift&Smart
Member
 
Registered: Jan 2003
Location: Hong Kong,China
Distribution: Slackware,OpenSUSE
Posts: 472

Original Poster
Rep: Reputation: 30
Unhappy Stupid...

Thanks for your reply iceman47.However,how stupid that I am!I don't understand your code.Would you mind telling me in an example?

Quote:
e.g. useradd blah blah blah -p my_password
Thanks.
 
Old 09-29-2003, 11:14 AM   #4
coolamit78
Member
 
Registered: Aug 2003
Location: New Delhi, India
Distribution: RHEL AS 3/4, Windows XP
Posts: 546

Rep: Reputation: 31
i think this should work...

log in as root

suppose u wanna add a user called 'swift'..then issue the following command..

useradd swift; passwd swift

then it will prompt u twice for the password....
 
Old 09-29-2003, 11:29 AM   #5
Swift&Smart
Member
 
Registered: Jan 2003
Location: Hong Kong,China
Distribution: Slackware,OpenSUSE
Posts: 472

Original Poster
Rep: Reputation: 30
Thanks,coolamit78.However,I intended to do it via PHP script with exec() function.So,I want to do this in "one" command line without any further prompt.

Thanks for all you guys every efforts to help me out.
 
Old 09-29-2003, 11:52 AM   #6
coolamit78
Member
 
Registered: Aug 2003
Location: New Delhi, India
Distribution: RHEL AS 3/4, Windows XP
Posts: 546

Rep: Reputation: 31
well....the -p option that is used with the useradd command needs an encrypted password, so u cant provide this password directly as it wouldnt be possible for u to perform the encryption manually. Therefore, u have to achieve this in some other indirect way. I am not in a position to suggest u anything right now....I'll sure, post a reply later after I try to do that with a single command..

good luck
 
Old 09-29-2003, 12:43 PM   #7
iceman47
Senior Member
 
Registered: Oct 2002
Location: Belgium
Distribution: Debian, Free/OpenBSD
Posts: 1,123

Rep: Reputation: 47
Re: Stupid...

Quote:
Originally posted by Swift&Smart
Thanks for your reply iceman47.However,how stupid that I am!I don't understand your code.Would you mind telling me in an example?
Sure, suppose that iceman is your name and you want your password to be letmein, do this:

Code:
adduser iceman; echo "letmein" | passwd iceman --stdin
 
Old 09-29-2003, 07:26 PM   #8
Swift&Smart
Member
 
Registered: Jan 2003
Location: Hong Kong,China
Distribution: Slackware,OpenSUSE
Posts: 472

Original Poster
Rep: Reputation: 30
Talking It worksssssssssssss!!!!!!

Wow,thanks a lot iceman47.It works!!!Thank you so much!
 
Old 09-29-2003, 09:05 PM   #9
iamthewind
Member
 
Registered: Sep 2003
Posts: 51

Rep: Reputation: 15
I did £¡ And it works £¡ ¹þ¹þ thanks everyone£¡
 
Old 09-30-2003, 03:37 AM   #10
coolamit78
Member
 
Registered: Aug 2003
Location: New Delhi, India
Distribution: RHEL AS 3/4, Windows XP
Posts: 546

Rep: Reputation: 31
adduser iceman; echo "letmein" | passwd iceman --stdin

Ok....i agree that this command rocks.....but I havent understood it entirely...

Now here, the output of echo is piped to the passwd command (this is what --stdin is actually doing....it takes the input as if it was coming through the standard input)

Now my question is....whenever we give the command 'passwd', it prompts us 2 times to enter the password. But here, the piped output of echo is just one out of the total 2 times....then how come it does not ask for password rentry??

pls clarify..

thanks
 
Old 09-30-2003, 06:30 AM   #11
iceman47
Senior Member
 
Registered: Oct 2002
Location: Belgium
Distribution: Debian, Free/OpenBSD
Posts: 1,123

Rep: Reputation: 47
Quote:
Originally posted by coolamit78

Now my question is....whenever we give the command 'passwd', it prompts us 2 times to enter the password. But here, the piped output of echo is just one out of the total 2 times....then how come it does not ask for password rentry??
Because that's just what the --stdin does, it takes whatever is been offered on that moment and uses it as the password, no verification needed.
 
Old 10-11-2003, 12:29 AM   #12
Swift&Smart
Member
 
Registered: Jan 2003
Location: Hong Kong,China
Distribution: Slackware,OpenSUSE
Posts: 472

Original Poster
Rep: Reputation: 30
Unhappy New problem....

It's me again.. Anyway,back to the problem.

Indeed,this script works fine when I execute it via command line (PHP).But what I exactly wanna do is when someone signs up,it will automatically add a user on my server.However,this script can only be executed by ROOT.Indeed,it's somehow very dangerous... My question is,how can I run this script in a more secure way/how to run it as ROOT?

Many thanks.
 
Old 10-11-2003, 08:23 AM   #13
Shade
Senior Member
 
Registered: Mar 2003
Location: Burke, VA
Distribution: RHEL, Slackware, Ubuntu, Fedora
Posts: 1,418
Blog Entries: 1

Rep: Reputation: 46
dude... NOT SAFE.

You're basically allowing *everyone* user-level access to the system... How do you mean, "when someone signs up"... Signs up how?

While you rethink that, read up on the setuid utility for executing the script.

Code:
man setuid
-Shade
 
Old 10-11-2003, 11:01 AM   #14
Swift&Smart
Member
 
Registered: Jan 2003
Location: Hong Kong,China
Distribution: Slackware,OpenSUSE
Posts: 472

Original Poster
Rep: Reputation: 30
Wink What I mean...

dude,thanks for your reply.

What I mean is that when someone signs up as my website's member,I want my system automatically adds them to my server.So I don't have to do it on my own everytime.

Do you know what I mean?Thanks.
 
Old 10-11-2003, 11:32 AM   #15
mossy
Member
 
Registered: Aug 2003
Location: USexIRL
Distribution: *nix
Posts: 849

Rep: Reputation: 30
I take it you want to let people register a uid and password for your site -
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to list user in Linux box, add an user to a group! steady_lfcfan Linux - Newbie 12 01-27-2013 01:14 PM
Help! Cannot Add a User to User Manager or Change Root Password lennysokol Linux - General 2 06-25-2005 09:59 AM
Samba 3.0: net user add - problem with password geodo Linux - Networking 1 12-06-2004 11:52 AM
Add User Problem.. chunk2609 Mandriva 2 05-31-2004 08:05 PM
Add user problem... X11 Linux - General 1 03-21-2002 04:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration