Bulk Linux Users Creation

Anass Assim - Oct 18 - - Dev Community

Bulk User Creator (Linux)

Description

This script automates the bulk creation of user accounts on a Linux system. It prompts for the username and the number of users to create. Usernames are generated based on the input and stored in a CSV file. Each user is created with a default password that matches their username.

Requirements

  • Linux environment
  • useradd command available
  • To encrypt the password of the users using mkpasswd , is it necesarry to install whois Packet.
   sudo apt install whois
Enter fullscreen mode Exit fullscreen mode

Installation

  1. Clone the repository:
   git clone https://github.com/ciscoAnass/Bulk-Linux-User.git
   cd Bulk-Linux-User
Enter fullscreen mode Exit fullscreen mode
  1. Make the script executable:
   chmod +x BulkUsers.sh
Enter fullscreen mode Exit fullscreen mode

Creating a Command Alias (Optional but recommended)

  • Add the following line to your shell configuration file (e.g., ~/.bashrc for bash):
echo "alias bulkuser='sudo ~/Bulk-Linux-User/BulkUsers.sh'" >> ~/.bashrc
Enter fullscreen mode Exit fullscreen mode

Then, apply the changes:

source ~/.bashrc
Enter fullscreen mode Exit fullscreen mode

Usage

Now you can use the bulkuser alias in your terminal to run the script with parameters. Here's how:

  • To create 7 users with the username "poppy" (You can choose whatever Username you want to create , also numbers):
bulkuser poppy 7
Enter fullscreen mode Exit fullscreen mode
  • This will generate output similar to:
User : poppy1 , Password : poppy1
User : poppy2 , Password : poppy2
User : poppy3 , Password : poppy3
User : poppy4 , Password : poppy4
User : poppy5 , Password : poppy5
User : poppy6 , Password : poppy6
User : poppy7 , Password : poppy7
Enter fullscreen mode Exit fullscreen mode
  • Additionally, it will create a UsrAccess-poppy.csv file containing the usernames and passwords.

Verification

To verify that the users have been created correctly, follow these steps:

  1. Check User Accounts: List the last 7 users created on the system to ensure they have been created:
   getent passwd | tail -7 | cut -d: -f1
Enter fullscreen mode Exit fullscreen mode

Notes

  • Ensure you have the necessary permissions to execute user creation commands (useradd).
  • Consider security implications when using default passwords.
. . . . .
Terabox Video Player