Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2014
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. #!bin/bash
  2. #Linux Lab 9
  3. #Mohamed Ashour
  4. #040766794
  5. #Section 401
  6. #myscript
  7. #2014-04-07
  8. #
  9.  
  10. choice=n
  11.  
  12. while [ $choice != "Q" ] && [ $choice != "q" ]
  13. do
  14. clear
  15. echo "A) Create a user account"
  16. echo "B) Delete a user account"
  17. echo "C) Change supplementary group for a user account"
  18. echo "D) Change the initial group for a user account"
  19. echo "E) Change the default login shell for a user account"
  20. echo "F) Change the account expiration date"
  21. echo "Q) Quit"
  22.  
  23. echo -n "Enter an option: "
  24. read choice
  25.  
  26. if [ $choice == "A" ] || [ $choice == "a" ]
  27. then
  28. clear
  29. read -p "Enter username: " username
  30. read -p "Enter the home directory for $username: " homeD
  31. read -p "Enter the login shell for $username : " loginS
  32. sudo useradd $username -m -d $homeD -s $loginS
  33. echo "User $username created with directory $homeD and login shell $loginS"
  34. sleep 3
  35. elif [ $choice == "B" ] || [ $choice == "b" ]
  36. then
  37. clear
  38. read -p "Enter user to delete: " username
  39. sudo userdel -r $username
  40. echo "User $username deleted"
  41. sleep 3
  42. elif [ $choice == "C" ] || [ $choice == "c" ]
  43. then
  44. clear
  45. read -p "Enter username to change supplementary group: " username
  46. read -p "Enter new supplementary group: " suppGroup
  47. sudo groupadd $suppGroup
  48. sudo usermod -G $suppGroup $username
  49. echo "User $username supplementary group changed to $suppGroup"
  50. sleep 3
  51. elif [ $choice == "D" ] || [ $choice == "d" ]
  52. then
  53. clear
  54. read -p "Enter username to change initial group: " username
  55. read -p "Enter new initial group: " initGroup
  56. sudo groupadd $initGroup
  57. sudo usermod -g $initGroup $username
  58. echo "User $username initial group changed to $initGroup"
  59. sleep 3
  60. elif [ $choice == "E" ] || [ $choice == "e" ]
  61. then
  62. clear
  63. read -p "Enter the username to change login shell: " username
  64. read -p "Enter new login shell: " loginShell
  65. sudo chsh -s $loginShell $username
  66. echo "User $username login shell changed to $loginShell"
  67. sleep 3
  68. elif [ $choice == "F" ] || [ $choice == "f" ]
  69. then
  70. clear
  71. read -p "Enter username to change expiration date: " username
  72. read -p "Enter new expiration date: " date
  73. sudo usermod -e $date $username
  74. echo "User $username expiration date changed to $date"
  75. sleep 3
  76. else
  77. echo "ERROR: INVALID INPUT"
  78. sleep 3
  79. fi
  80. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement