Question
You are asked to write a shell script that will create user accounts and set their home directories. The script will be running in an
You are asked to write a shell script that will create user accounts and set their home directories. The script will be running 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:
Your script will read the account information from a text file which has the following format
FirstName,LastName,PhoneNumber,email
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
Your script must also create a random password for each user.
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.
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.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started