Posted: . At: 1:04 PM. This was 10 years ago. Post ID: 7477
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.


Useful shell script that may be used to create a whole host of user accounts easily.


This bash shell script is useful for creating a new user and setting a password for that user. This allows you to just type a username and password and everything else is done for you. Very useful for someone who is in a hurry.

#!/bin/bash
 
echo "Type a username for your new account: "
read username
 
echo "Type a password for your new account: "
read password
 
# Creating our new account.
 
useradd -m -s /bin/bash -d /home/$username $username
 
# Setting a hashed password for our new user.
 
echo "$username:$password" | chpasswd
 
echo Username: $username
echo Password: $password

Give this script a try and see what you think of this. I will make improvements to this script and put it on githb when I get the chance.


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.