Last active
August 20, 2024 06:05
-
-
Save dpastoor/ccf18adbac865a2253ca941928f6d923 to your computer and use it in GitHub Desktop.
adding users
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
users=`ls /data/home/` | |
folder="FOLDER" | |
for i in $users; do | |
echo "Copying to $i" | |
cp -R /data/$folder /home/$i/ | |
rm -rf /home/$i/$folder/.git | |
rm -rf /home/$i/$folder/.Rproj.user | |
chown -R $i: /home/$i/$folder | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
FILENAME=users.csv | |
OLDIFS=$IFS | |
IFS=, | |
while read user pw email | |
do | |
if [ "$user" == "user" ]; then | |
continue; | |
fi | |
if [ "$user" == "sgeadmin" ]; then | |
continue; | |
fi | |
if [ "$user" == "ubuntu" ]; then | |
continue; | |
fi | |
echo "creating user $user" | |
#userdel -r $user | |
#rm -rf /home/$user | |
useradd $user -s /bin/bash && echo "$user:$pw" | chpasswd | |
mkdir /home/$user && chown $user:$user /home/$user | |
addgroup $user staff | |
done < $FILENAME | |
IFS=$OLDIFS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Add 100 users for teaching sessions | |
for u in {0..100} | |
do | |
useradd user$u && echo "user$u:user$u" | chpasswd | |
mkdir /home/user$u && chown user$u:user$u /home/user$u | |
addgroup user$u staff | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"tags": [ | |
"bash", | |
"unix", | |
"administration" | |
], | |
"languages": [ | |
"bash" | |
], | |
"references": [ | |
"https://github.com/rocker-org/rocker/blob/b026698d52ddf8f52bf5b3ec94c708397751d2ed/rstudio/testing/add-students.sh" | |
] | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment