Contact us

Print

Manually creating a new user

So far throughout the previous labs you have been using the system in the capacity of the most powerful user on the system – the root user. In a production environment, this is not good practice because it makes the system vulnerable, security wise. The root user can, do and undo unlimited damage to the system.
Other than the superuser, every other user has limited access to files and directories.
Always use your machine as a normal user. Two confusing concepts will be made clear here.

Firstly the home directory of the root user is “ /root “.

Secondly the root directory is the topmost directory, known as the / (slash) directory.
(“/root” is very different from “/ “)

In this lab you will create a new user called “Me Mao”. The user name for “Me Mao will” be the first name- “me”. This new user will belong to the group “me”. The password will be “a1b2c3”

When editing configuration files, never write out a line from scratch because it may have a special/specific format. Instead copy an existing entry that has proved itself to be correct, and then edit in the appropriate changes. This will prevent you from making errors.


1. Log in to the computer as root

2. Use the tail command to view the last 4 entries at the bottom of the /etc/passwd file.


[root@localhost root]# tail -n 4 /etc/passwd

apache:x:48:48:Apache:/var/www:/sbin/nologin
xfs:x:43:43:X Font Server:/etc/X11/fs:/sbin/nologin
ntp:x:38:38::/etc/ntp:/sbin/nologin
gdm:x:42:42::/var/gdm:/sbin/nologin




You will edit the passwd file using the format displayed above.


To create the user


A.) Editing the /etc/passwd file

1. Launch your editor of choice and open up the file “/etc/passwd”

2. Add the text below to the bottom or end of the file :


me:x:500:500:me mao:/home/me:/bin/bash


3. Save your changes and close the passwd file.

B.) Editing the /etc/shadow file

5. Launch your editor and open up the “/etc/shadow” file.
6. Add a new entry like the one below to the bottom of the file - put an asterisk ( * ) in the password field. Type:

me:*:11898:0:99999:7:::


7. Save your changes and close the shadow file.

C.) Editing the /etc/group file.

8. Launch your editor and open up the “/etc/group” file.

9. At the bottom of the file add a new entry like:

me:x:500:me


10. Save your changes and close the group file.


D.) Creating the home directory

11. Copy the entire contents of the “/etc/skel” directory into /home directory, renaming
the new directory to the name of the user i.e. “/home/me”. Type :

 [root@localhost root]# cp   –r   /etc/skel    /home/me



12. The root user owns the directory you just created, because she created it. In order for the user “me mao” to be able to use the directory you will change the permissions/ownership of the folder. Type:


 [root@localhost root]# chown  –R   me:me    /home/me		




E.) Creating a password for the user.

13. You will use the “passwd” utility. Type “passwd” and follow the prompts
(the new password is “a1b2c3”):

[root@localhost root]# passwd   me 
      
  	Changing password for user me.
New password:
Retype new password:
passwd: all authentication tokens updated successfully. 




14. Logout of the system when you are done.


Created by: system. Last Modification: Saturday 04 of April, 2009 22:07:59 EST by wale.

...