开发者

Ubuntu Linux useradd with -p option [closed]

Closed. This question is off-topic. It is not currently accepting answers.

Want to improve this question? Update the question so it's on-topic for Stack Overflow.

开发者_JS百科

Closed 11 years ago.

Improve this question

I'm trying to add a user in Ubuntu Linux 11.04 with a single useradd directive.

I found something similar here but I can't seem to figure it out completely: Useradd using crypt password generation

Let's say my username is ohill and my password is justpass, what would the command line directive be exactly? Here is what I have so far that I borrowed from the above link.

useradd -p $(perl -e 'print crypt("justpass", "aa")') -g sudo -s /bin/bash -m ohill

It doesn't seem to work and I'm sure I'm missing something.

Any ideas or an easier way? I'm looking for something I can easily put in a shell script.


I settled for the following:

useradd {myusername} -g sudo -s /bin/bash -m
echo "{myusername}:{mypassword}" | chpasswd

It's two lines but it does the business.

So my command line directive given the username and password in my initial question above would be:

useradd ohill -g sudo -s /bin/bash -m
echo "ohill:justpass" | chpasswd

I hope it comes in handy for someone else.

Cheers.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜