Lab 2A> ADDING USERS in Linux Objective In this lab, student will learn how to create user accounts using the Linux operating system. Scenario The XYZ Company has just installed a server running Linux. The company needs an IT personnel to log onto the server and create users account so that users can log in to the server. Procedures You need to create 5 users as follows: Username: Password: TomTimm default123 ChristyTan 123default BenjaminLim password07 JohnGram 07password MarkWebber 12345678 Step 1: Log in to the Linux server as root: Username: root Password: get from Instructor Open a terminal console > Click Applications > System Tools > Terminal Step 2: The useradd Command At the command prompt, type the command: useradd TomTimm and hit enter. Step3: The passwd Command At the command prompt, type the command: passwd TomTimm and hit enter. The system will ask you to enter a new password. Type default123 and hit enter. The system will ask you to Retype new password. Type deault123 and hit enter again. The system will display token updated successfully. Step4: Test the account At the command prompt, type the command: su TomTimm and hit enter. The system will bring you to TomTimm account. Type su - and hit enter to return to root account. Type the root password if prompted.
Repeat Step 2 to 4 for the other 4 accounts. Step 5: Deleting Users To delete an account, the Linux administrator uses the userdel command. To verify user account TomTimm created earlier, type: finger TomTimm There should be a home directory created. Next delete the account, type: userdel r TomTimm Verify the user account existence by typing:
finger TomTimm As you can see, there is no such user as TomTimm which means the userdel r command has deleted the user TomTimm plus the home directory. Lab 2B - Creating Groups in Linux Objective In this lab, the student will learn how to create, rename, and delete groups using the Linux operating system. The student will then add members to that group. Scenario A few members in the Engineering Department, who are using Linux, are going to be working on classified documents. They need to have their own group created so they can keep these documents in certain folders that only their group will have permissions to. A group must be created and members added to this group. Procedures In this lab, the student will first create the engineering group and then add the localuser1 user account to this group. The student will then rename the group. For the last step, the student will delete the group. Tips Before You Begin, Remember: User permissions apply to the owner of the file or directory. Group permissions apply to the members of the group that are assigned to a file or directory. Linux stores group information in the /etc/group file.
Creating a Group and Adding Users to the Group Note: The account studenta5 will be used throughout this lab as an example. 1. Login with the root account. 2. At the command prompt, type: useradd studenta5 passwd studenta5 enter the password when prompted> password123 enter the password again when prompted> password123 3. Now type groupadd Engineering Press Enter. This will create the Engineering group. 4. Verify that the new group has been created by typing: grep Engineering /etc/group The grep command looks for strings of text. In this case, the user asked the grep command to look in the /etc/group file for anything named Engineering. The result is as follows: From the above, a group called Engineering has been created but there is no user attached to it. 5. Next, add a student account to the new Engineering group by typing: usermod G Engineering studenta5 Press Enter. This will add the studenta5 account to the Engineering Group.
6. Verify that user studenta5 has been added to the Engineering group by typing: grep Engineering /etc/group The grep command looks for strings of text. In this case, the user asked the grep command to look in the /etc/group file for anything named Engineering. The result is as follows: From the above, user studenta5 belongs to a group called Engineering. Next we will create a directory for the Engineering group. 7. As the root user, go to the /home directory: cd /home 8. Create a new directory: mkdir Eng 9. Verify that the new directory exists: ls l note that root is currently the owner of this directory 10. Change the ownership of the Eng directory from root to Engineering with the following command: chgrp Engineering Eng 11. Verify that ownership has changed from the root to Engineering: ls l
Now the group has changed to Engineering for the directory called Eng Next we are going to change the permission of the directory called Eng. But before that, note the permission of the directory called Eng as shown below: 12. Change the permissions of the Engineering directory: chmod 771 Eng 13. Verify that permissions of the directory have changed: ls -l
Note: The owner of the Eng directory is the root user. The group is called Engineering Both the root account and the Engineering group have the same Read, Write, and execute permissions. In the last group, everyone has execute privileges only. Creating Files in the Eng Directory 14. Switch users from root to the studenta5 account: If you are studenta5 then ignore this step and go to step 15 su studenta5 15. Go into the Eng directory: cd /home/eng 16. Create a file, type: touch file123 17. Verify that the new file was created: ls l 18. Now switch user to a studenta1 who is not a member of the Engineering group: su studenta1 19. Go to the /home/eng directory: cd /home/eng
20. Create a file: touch grp_file1 You will notice that StudentA1 does not have permission to create the file because it does not belong to the group called Engineering. Deleting the Eng directory 21. Log back in as the root user: su root Enter the password and press Enter. 22. Verify that you are the root user: whoami 23. Go to the /home directory: cd /home 24. Delete the Eng dir and its contents: rm r Eng When prompted to descend into directory Eng, type Y for yes. When prompted to delete the files, type Y for yes. When prompted to delete the directory, type Y for yes.
25. Verify that the Eng directory has been removed: ls l Eng directory is no longer there. Let us now learn how to renaming a Group 26. At the command prompt, type: groupmod n New Engineering Press Enter. This will rename the group from Engineering to New. 27. Verify that the group name changed: grep New /etc/group
Last but not least, we will learn how to delete a Group 28. At the command prompt type: groupdel New Press Enter. This will delete the group. 29. Verify with the grep command: grep New /etc/group The output should not have a group called New.