###shell script that will mange your user and groups in debian/ ubuntu system
writer: anuj borah
email: anujborah1@gmail.com
#!/bin/bash
clear
echo "*******************Script that will make manage user and groups for you ************************** "
echo "*********** You have the following options from my side *************"
echo -e "1.Create User(press 1)\n2.Create Group(press 2)\n3.Delete User(press 3)\n4.Delete Group(press 4)\n5.Add any user to any Group(press 5)"
read p
if [ $p -eq 1 ]
then
echo "Give me the name of user u want to create...... "
clear
echo "Password and other info have to be filled by u ...... "
read q
sudo adduser $q
echo "Now tell me you want this $q user a \n1.sudoder(press 1) \nor \n2.nonsudoder(press 2) ???"
if [ $p -eq 1 ]
then
echo
sudo echo "$q ALL=(ALL:ALL) ALL" >> /etc/sudoers 1>/dev/null
clear
echo ":::::: OK all done now $q is a sudoder user:::::::::::"
else
clear
sleep 3
echo "ok everything done"
fi
elif [ $p -eq 2 ]
then
echo "Give me the name of group ...."
read q
groupadd $q
clear
echo "Now the group $q created. ... "
elif [ $p -eq 3 ]
then
clear
echo "Give me the name of the user u want to delete .... "
read q
grep $q /etc/passwd && deluser --remove-home $q || echo "user not found"
clear
echo "User $q deleted.... "
elif [ $p -eq 4 ]
then
echo "Give me the name of group u want to delete ...."
read q
grep $q /etc/passwd && groupdel $q || echo "Group not found."
clear
echo "All done"
elif [ $p -eq 5 ]
then
echo "give me the name of user and group.... "
read q w
grep $q /etc/passwd && echo "`usermod -G $w $q` `clear` "All Done"" || echo "No such user or group";
fi
No comments:
Post a Comment