Contact us |
Automatically creating a new userThere are loads of utilities available to simplify all the tasks/steps that we manually performed in the previous exercise. We only walked through the manual process of creating a user, so that you can see what actually goes on in the background.In this exercise we will use some common utilities to manage and simplify the process. You will create another user account for the user “Ying Yang” the login name will be “ying”. And the password for ying will be “y1i2n3”. You will also create a group called “common” and add the user me and ying to the group. To automatically create a new account 1. Login to the system as root. 2. You will create the user ying using all the defaults of the “useradd” command. Type: root@localhost root# useradd -c "Ying Yang" ying 3. Use the tail command to examine the addition you just made to the /etc/passwd file. Type: root@localhost root# tail -n 4 /etc/passwd pcap:x:77:77::/var/arpwatch:/sbin/nologin me:x:500:500:me mao:/home/me:/bin/bash ying:x:501:501: Ying Yang:/home/ying:/bin/bash List the new entry here? 4. The user ying will not be able to login to the system until you create a password for the user. Type: root@localhost root# passwd ying Changing password for user ying. New password: Retype new password: passwd: all authentication tokens updated successfully. 5. Use the “id” utility to quickly view information about the new users you just created. Type: root@localhost root# id me uid=500(me) gid=500(me) groups=500(me) and then type: root@localhost root# id ying uid=501(ying) gid=501(ying) groups=501(ying) To automatically create a new group 1. Use the groupadd program to create the new group “common”. root@localhost root# groupadd common 2. Examine the tail end of the /etc/group file to see the new addition. What is the command to do this? 3. Unfortunately there is not standard program to add existing users to a group. (except you do it while creating the user. You will do it manually by editing the /etc/group file. Run the tail command on the group file. root@localhost root# tail -n 5 /etc/group me:x:500:me ying:x:501: common:x:502: 4. Edit the last entry for the common group you created by appending “me,ying” after the last semi-colon. 5. Launch your text editor and change the last line in the group file from: common:x:502: Change To: common:x:502:me,ying 6. Save your changes and exit the group file. 7. Run the “id” command again on user “ying”. What has changed? To modify a user account 1. Use the usermod command to change the comment field for the user “me”. The new comment you will add will be “first last”. Type: root@localhost root# usermod -c "first last" me Use the tail command to examine your changes to the /etc/passwd file. Write the changed line below? 2. What is the user me’s login shell ? 3. Use the “usermod” command again to change me’s login shell to the csh shell. Type: root@localhost root# usermod -s /bin/csh me 4. Finally use the “usermod” command to undo all the changes you made to the user “me” above. Return the values ( login shell etc..) to their original values. Write down the commands to do this?
|
Login... |