Linux - SoftwareThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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??
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.
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..
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:
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??
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.
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?
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.