This bash script creates 35 users and 7 groups, and must be run as root. It checks for existing groups and users, creates them if they do not exist, and logs the actions taken. A default password is set for all users, and a super administrator is also created.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
4 views2 pages
Creer Utilisateurs
This bash script creates 35 users and 7 groups, and must be run as root. It checks for existing groups and users, creates them if they do not exist, and logs the actions taken. A default password is set for all users, and a super administrator is also created.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2
#!
/bin/bash
# SCRIPT: creer_utilisateurs.sh - Create 35 users and 7 groups
# Must be run as root if [[ $EUID -ne 0 ]]; then echo "Error: This script must be run as root." >&2 exit 1 fi
# Declare associative array for groups and their users
declare -A groupes_utilisateurs=( ["profs"]="alice bob claire david emilie" ["eleves"]="franck gina Henri isabelle jacques" ["admins"]="karim laura marc nora olivier" ["support"]="paul quentin rita sam theo" ["visiteurs"]="ursula victor wendy xavier yasmine" ["compta"]="zach lea mike nina omar" ["direction"]="pierre clara lucie julien sophie" )
# Default password and log file
default_password="Password123!" # Consider generating random passwords log_file="/var/log/utilisateurs_groupes.txt"
echo "=== User and Group Creation Log - $(date) ===" > "$log_file"
# Create groups and users
for groupe in "${!groupes_utilisateurs[@]}"; do # Create group if it doesn't exist if ! getent group "$groupe" >/dev/null 2>&1; then groupadd "$groupe" echo "Created group: $groupe" >> "$log_file" else echo "Group $groupe already exists" >> "$log_file" fi