-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_user.sh
More file actions
executable file
·30 lines (21 loc) · 971 Bytes
/
create_user.sh
File metadata and controls
executable file
·30 lines (21 loc) · 971 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash
# Above first line specifies that this script should be run using the Bash shell
<<helpText
this is a shell script to create user
helpText
# Above is a multiline comment block (here-doc) used for internal script documentation
# User Create
function create_user {
echo "======Creation of User======"
# Prompt the user to enter a username and store it in the variable 'userName'
read -p "enter the username: " userName
# Prompt the user to enter a password and store it in the variable 'password', -s flag hide the password from input screen
read -sp "enter the password: " password
# Create a new user with a home directory using the provided username
sudo useradd -m "$userName"
# Set the password for the new user (echoing twice for confirmation)
echo -e "$password\n$password" | sudo passwd "$userName"
echo "========User creation Completed======="
}
# Call the create_user function to execute user creation steps
create_user