Question: User account creation script You are asked to write a shell script that will create user accounts and set their home directories. The script will
User account creation script
You are asked to write a shell script that will create user accounts and set their home directories. The script will be ran in an Ubuntu server so make sure to research the use of the useradd command in this flavor of linux. The account creation will be as follows:
Input file format
Your script will read the account information from a text file which has the following format
FirstName,LastName,PhoneNumber,email
Reading the File
Your script will read the file line by line and will create the account as follows
Your script must generate a user name with the following format
FirstLetterOfFirstNameLastName
Example
for user Luis Barreto, the user name created must be lbarreto. In case the user name is already taken your script must add a number from 1 to as many numbers needed. Some repeated user names could be of the following format:
lbarreto
lbarreto1
lbarreto2
The user account's password
Your script must also create a random password for each user. In order to do this, you will need to install a tool called pwgen
sudo apt-get install pwgen
To generate the password on the command line type:
pwgen 14 1
This generates a string of 14 characters
Creating the account
Once you have those two components, your script must execute the useradd command. After the account was successfully created, your script must create a public_html directory under the users home directory.
Log File
After the user account is created and its home directory is configured correctly, your script must output the username, password and home directory absolute path to a userCreation.log file.
Deliverable (3 Files)
You must submit your shell script, user creation log file and the input file by uploading it
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
