Jump to content











Photo
- - - - -

Script for adding users automatically


  • Please log in to reply
No replies to this topic

#1 Mikorist

Mikorist

    ▂ ▃ █ ▅ ▆

  • Advanced user
  • 771 posts
  •  
    United Nations

Posted 13 March 2009 - 07:56 PM

To add new users to the Linux shell using the commands "adduser" and "useradd", which is then entered into the wizard asking for additional parameters. However, sometimes it is necessary that the user is added automatically, which will be forwarded only username and password parameters, without any wizard. So automatically add users!

Script that works the thing looks like this:

#!/bin/bash
username=$1
password=$2
pass=$(perl -e ‘print crypt($ARGV[0], “password”)’ $password)
useradd -m -p $pass $username

usage:

$. /script username password

Very simple and very useful thing ...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users