Question: Please do this assignment by using Perl Language. Provide code and screenshot please. The process of creating a user Linux ID can be done in

Please do this assignment by using Perl Language. Provide code and screenshot please.

The process of creating a user Linux ID can be done in three different ways; - Using GUI, if provided by the server - Using the Linux command adduser to add user ID - Or, manually edit all necessary files i.e. /etc/passwd, /etc/group, /etc/shadow, create

the home directory and set the permission

Depending on your server environment and requirements, sometimes the above process does not fit your need. Therefore you may have to write your own login ID script. For this exercise, you have to write a shell script program to add user ID. The program will ask a user to enter the following information interactively;

1. User full name 2. User's choice of Linux ID account 3. Phone number

Once the information is entered, your program should enter the information into the appropriate files - /etc/passwd, /etc/group and /etc/shadow files. Since you do not have root access, we will skip the shadow file and you need to copy two files only; /etc/passwd and /etc/group into your home directory and work on them instead of working with the actual files.

What should be entered into a password file:

Append a new line at the bottom of the file that consists of user's choice of Linux ID on

the first field. This ID must be unique. So you need to check the password file first when accepting a user' s ID to make sure that there is no duplicate. If the ID already exists, ask the user to enter a different choice.

Enter letter x on the second field of the line (This is the password field that gets created in the shadow file at a later time)

The third and fourth fields of the password file are the UID and the GID respectively. This number must be the last number +1 from the last line in the password file. For example if the last line in the password file has UID 558, then your new user UID and GID should be 559

The fifth field is your user full name and the phone number. This is for the System Administrator to know who owns the ID, and the contact phone number

The sixth field is your user's home directory. For now, because you do not have root access, use your home directory as the user's home directory. So, your new user's home directory will be $HOME/new_user_id. Your program then create this user's home directory and give the user a new .bash profile file. You can copy the .bash_profile from directory /etc/skel (system provided profile).

Adding Login Account on Linux System

2

Field seven is the user's choice of shell type. Use /bin/bash Here is an example of an entry line in a passwd file;

braatzr:x:558:558:Richard Braatz, 229-2865:/export/home/braatzr:/bin/bash

What should be entered into a group file; Append a line at the end of group file with the user's ID and the GID number. Example; braatzr:x:558:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!