DEV Community

Anass Assim
Anass Assim

Posted on

2

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

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay