single command

  • praveen278
  • Novice
  • Novice
  • praveen278
  • Posts: 22
  • Loc: INDIA

Post 3+ Months Ago

Hi ,

Is there any command in linux so that i can create a user and password in single command line.

"useradd -p " is not working .
  • Don2007
  • Web Master
  • Web Master
  • Don2007
  • Posts: 4924
  • Loc: NY

Post 3+ Months Ago

useradd works in a single line but more options have to be used.

useradd -m -s -d /home/name -p passwd -s bash name

It's something like that.

Read the man page.
  • praveen278
  • Novice
  • Novice
  • praveen278
  • Posts: 22
  • Loc: INDIA

Post 3+ Months Ago

Actually my requirement is only adding a user and password for that user in single line command.
  • Don2007
  • Web Master
  • Web Master
  • Don2007
  • Posts: 4924
  • Loc: NY

Post 3+ Months Ago

That's your requirement. What about the machine's requirement? Besides, I gave you a single line command. If the extra inch is too much for you to type, you're in the wrong business.
  • geekdw
  • Beginner
  • Beginner
  • User avatar
  • Posts: 39

Post 3+ Months Ago

Unfortunately there is no way to just type in a username and password and have the system add it unless you write your own script. Otherwise the above works.

Someone here could probably write a little shell script pretty easily that'll allow you to do that. Just pass a few parameters.
  • AnarchY SI
  • Web Master
  • Web Master
  • User avatar
  • Posts: 2521
  • Loc: /usr/src/MI

Post 3+ Months Ago

meh..theres no need to reinvent the wheel.. just search google >.<
http://lists.freebsd.org/pipermail/free ... 11012.html

this may work or some concoction doing the same thing.. the password being the word in quotes, of course.
  • eggi
  • Novice
  • Novice
  • eggi
  • Posts: 30

Post 3+ Months Ago

Hey there,

The only way you could get away with this is if you connected to commands on a single line and your version of passwd (Gnu) supports the --stdin option. Otherwise, you'd need to use Expect or some other tool to do the job.

On the other hand, if you have access, you can use awk to mangle /etc/passwd and /etc/shadow and then pwconv, but I would "strongly advise doing that." You may add one user and remove access for everyone ;)

,Mike
  • AnarchY SI
  • Web Master
  • Web Master
  • User avatar
  • Posts: 2521
  • Loc: /usr/src/MI

Post 3+ Months Ago

.. "strongly advise against ..." ?
  • Don2007
  • Web Master
  • Web Master
  • Don2007
  • Posts: 4924
  • Loc: NY

Post 3+ Months Ago

How much longer is this thread going to go because the original poster didn't want to type a few extra words? He can't be a Linux administrator.
  • eggi
  • Novice
  • Novice
  • eggi
  • Posts: 30

Post 3+ Months Ago

AnarchY SI wrote:
.. "strongly advise against ..." ?


Yes, against. Wow - Never in the last few weeks, at least, has typing too fast and leaving out a word completely made me sound like an idiot ;)

Thanks for pointing that out.

Please; don't do it! :)

, Mike
  • kc0tma
  • o|||||||o
  • Web Master
  • User avatar
  • Posts: 3318
  • Loc: Trout Creek, MT

Post 3+ Months Ago

I'm still wondering why useradd isn't good enough. Thats a single command, and I bet you could even make a shell script or perl script that could create multiple accounts and passwords in one single command with a text file for input.

//sorry if this came out garbled, I'm finishing a beer after two rum & cokes.
  • AnarchY SI
  • Web Master
  • Web Master
  • User avatar
  • Posts: 2521
  • Loc: /usr/src/MI

Post 3+ Months Ago

Quote:
-p, --password PASSWORD
The encrypted password, as returned by crypt(3). The default is to disable the account.

- http://linux.die.net/man/8/useradd


don - i'm not a linux admin either ^_^

Post Information

  • Total Posts in this topic: 12 posts
  • Users browsing this forum: No registered users and 88 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.