Ajout de createUsers.sh
This commit is contained in:
parent
a1aba478f6
commit
97c1eaba8b
18
sisr1/tp04_scripts_admin/tp04/createUsers.sh
Normal file
18
sisr1/tp04_scripts_admin/tp04/createUsers.sh
Normal file
@ -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
|
Loading…
x
Reference in New Issue
Block a user