Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Part 1: Working in your CentOS Linux machine, find out the steps to add users to

ID: 3808949 • Letter: P

Question

Part 1: Working in your CentOS Linux machine, find out the steps to add users to the system (regular user accounts) without using any tool (like useradd, or a GUI, or anything alike). You must add them “manually” (understand this as modifying the right files, creating the appropriate directories with appropriate files in them, and setting the appropriate ownership and permissions on the directories and files). The user must be able to log in using a password (which could be set on the first log in attempt) into the system to their home directory. The user’s home directory should also include the following directories: Documents, Desktop, Downloads, and Public.

Part 2: Create a shell script that would receive as a parameter (from the command line) the number of days from epoch (January 1, 1970) and display the date in a human readable way, please check the screen shot. Hint: There is a command, with the correct option, that you can use in Linux to convert the this, but it will convert the number of seconds since epoch, rather than the number of days.

Explanation / Answer

1.

To create a new account manually, follow these steps:

Edit /etc/passwd with vipw and add a new line for the new account. Be careful with the syntax. Do not edit directly with an editor. vipw locks the file, so that other commands won't try to update it at the same time. You should make the password field be `*', so that it is impossible to log in.

Similarly, edit /etc/group with vigr, if you need to create a new group as well.

Create the home directory of the user with mkdir.

Copy the files from /etc/skel to the new home directory.

Fix ownerships and permissions with chown and chmod. The -R option is most useful. The correct permissions vary a little from one site to another, but usually the following commands do the right thing:

Set the password with passwd.

After you set the password in the last step, the account will work. You shouldn't set it until everything else has been done, otherwise the user may inadvertently log in while you're still copying the files.

2.

Please note that @ feature only works with latest version of date (GNU coreutils v5.3.0+). To convert number of seconds back to a more readable form, use a command like this:

  date -d @1268727836 +"%d-%m-%Y %T %z"  
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote