0

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.

Community
  • 1
  • 1
ObiHill
  • 11,448
  • 20
  • 86
  • 135

1 Answers1

1

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.

ObiHill
  • 11,448
  • 20
  • 86
  • 135