Logo

dev-resources.site

for different kinds of informations.

Bulk Linux Users Creation

Published at
10/18/2024
Categories
linux
bash
ubuntu
debian
Author
Anass Assim
Categories
4 categories in total
linux
open
bash
open
ubuntu
open
debian
open
Bulk Linux Users Creation

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

Installation

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

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

Then, apply the changes:

source ~/.bashrc

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
  • 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
  • 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

Notes

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

Featured ones: