All projects

Linux administration · Bash

Linux account management from a CSV file, in Bash

A Bash script that reads employees from a CSV file, creates the department groups and the user accounts with random passwords, and can be run again without creating duplicates. Published with a small system health-check script.

Period
August 2026
Status
Completed · personal project, during my internship
Type
Personal project
  • Bash
  • useradd / groupadd
  • chpasswd
  • Ubuntu 24.04
  • Docker

The project

While practising Linux administration in August 2026, I wanted to stop creating accounts by hand. I documented the scripts in a PDF report at the time; the original files were later lost, so the published code is copied from that report. One line missing from the printed listing (the loop that reads the CSV) was restored and is marked with a comment.

What I did, and what went wrong

  • For each CSV line (first name, last name, department): create the department group if it doesn't exist, then the user first.last with a home directory, its own primary group and the department as a secondary group.
  • Generate a random 12-character password, set it with chpasswd and record it in credentials.txt.
  • health_check.sh prints the date, load average, memory, disk usage and the five processes using the most memory.

How I checked it

What I wanted to prove, the test I ran, and what I actually saw.

What I wanted to proveThe testWhat I saw
The first run creates the accountsRan on Ubuntu 24.04 in a throwaway Docker container with the sample CSV2 groups and 4 users created
The script can be run againSecond run with the same CSVEverything reported as already existing, nothing duplicated

Limits and next steps

  • Passwords are written in clear text to credentials.txt. On a real system they should be handed over another way and changed at first login (chage -d 0).
  • No validation of the CSV content (empty fields, spaces, accents in names), and no dry-run mode.

Code and documents

  • Repository github.com/AGRO-Rachidi/linux-user-management-bash