Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!bin/bash
- #Linux Lab 9
- #Mohamed Ashour
- #040766794
- #Section 401
- #myscript
- #2014-04-07
- #
- choice=n
- while [ $choice != "Q" ] && [ $choice != "q" ]
- do
- clear
- echo "A) Create a user account"
- echo "B) Delete a user account"
- echo "C) Change supplementary group for a user account"
- echo "D) Change the initial group for a user account"
- echo "E) Change the default login shell for a user account"
- echo "F) Change the account expiration date"
- echo "Q) Quit"
- echo -n "Enter an option: "
- read choice
- if [ $choice == "A" ] || [ $choice == "a" ]
- then
- clear
- read -p "Enter username: " username
- read -p "Enter the home directory for $username: " homeD
- read -p "Enter the login shell for $username : " loginS
- sudo useradd $username -m -d $homeD -s $loginS
- echo "User $username created with directory $homeD and login shell $loginS"
- sleep 3
- elif [ $choice == "B" ] || [ $choice == "b" ]
- then
- clear
- read -p "Enter user to delete: " username
- sudo userdel -r $username
- echo "User $username deleted"
- sleep 3
- elif [ $choice == "C" ] || [ $choice == "c" ]
- then
- clear
- read -p "Enter username to change supplementary group: " username
- read -p "Enter new supplementary group: " suppGroup
- sudo groupadd $suppGroup
- sudo usermod -G $suppGroup $username
- echo "User $username supplementary group changed to $suppGroup"
- sleep 3
- elif [ $choice == "D" ] || [ $choice == "d" ]
- then
- clear
- read -p "Enter username to change initial group: " username
- read -p "Enter new initial group: " initGroup
- sudo groupadd $initGroup
- sudo usermod -g $initGroup $username
- echo "User $username initial group changed to $initGroup"
- sleep 3
- elif [ $choice == "E" ] || [ $choice == "e" ]
- then
- clear
- read -p "Enter the username to change login shell: " username
- read -p "Enter new login shell: " loginShell
- sudo chsh -s $loginShell $username
- echo "User $username login shell changed to $loginShell"
- sleep 3
- elif [ $choice == "F" ] || [ $choice == "f" ]
- then
- clear
- read -p "Enter username to change expiration date: " username
- read -p "Enter new expiration date: " date
- sudo usermod -e $date $username
- echo "User $username expiration date changed to $date"
- sleep 3
- else
- echo "ERROR: INVALID INPUT"
- sleep 3
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement