From 97c1eaba8bdfb44fde09073a449e68cb06914d46 Mon Sep 17 00:00:00 2001 From: "yann.lereuille" Date: Thu, 20 Feb 2025 14:49:06 +0100 Subject: [PATCH] Ajout de createUsers.sh --- sisr1/tp04_scripts_admin/tp04/createUsers.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 sisr1/tp04_scripts_admin/tp04/createUsers.sh diff --git a/sisr1/tp04_scripts_admin/tp04/createUsers.sh b/sisr1/tp04_scripts_admin/tp04/createUsers.sh new file mode 100644 index 0000000..a559240 --- /dev/null +++ b/sisr1/tp04_scripts_admin/tp04/createUsers.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +file="./logins.csv" + +while read line +do + username=$(echo $line | cut -d ";" -f1) + # L'option -m crée le répertoire perso dans /home et -s indique le shell + useradd -m -s "/bin/bash" $username + group=$(echo $line | cut -d ";" -f5) + usermod -aG $group $username + password=$(echo $line | cut -d ";" -f2) + # Permet de changer le mot de passe + echo $username:$password | chpasswd + # Attribution des droits sur le répertoire personnel * + chown $username:$username /home/$username + +done < $file \ No newline at end of file