Introduction:
This bash script automates user account management tasks. It can create a new user, delete an existing user, or display user details, improving administrative efficiency.
Instructions:
To use this script, simply execute one of the following commands:
Example Output:
This bash script automates user account management tasks. It can create a new user, delete an existing user, or display user details, improving administrative efficiency.
Bash:
#!/bin/bash
show_help() {
echo "Usage: $0 {add|delete|info} username"
exit 1
}
if [ $# -ne 2 ]; then
show_help
fi
action=$1
username=$2
case $action in
add)
sudo useradd -m $username && echo "User $username added."
;;
delete)
sudo userdel -r $username && echo "User $username deleted."
;;
info)
id $username
;;
*)
show_help
;;
esac
Instructions:
To use this script, simply execute one of the following commands:
Code:
./user_mgmt.sh add newusername
./user_mgmt.sh delete newusername
./user_mgmt.sh info existingusername
Example Output:
Code:
uid=1001(newusername) gid=1001(newusername) groups=1001(newusername)