You are on page 1of 6

Worksheet-4

Student Name: Shailesh Kumar Rai UID:20MCA1260


Branch: MCA Section/Group:1-B
Semester: 1 Date of Performance:29.09.2020
Subject Name: Linux Lab Subject Code:20CAP618
Aim. To create users and groups on Linux OS and working with ACL’s.
Task to be done:
1. Create a user TOM with uid 2211 and assign a password “redhat”. Check that its entry exists in the
configuration file and check whether they can log in or not. Now check the name of primary group of
that user by visiting group configuration file. After check its availability in primary group, add that user
to the secondary group named GRP.

2. Create a file named file34 using vi editor and add the contents as following:

“Try not to become a man with Success,


But rather try to become a man of Value”

After this, store a command as content in this file to display the ACL of this file. Execute a command
used for writing or changing the acls of file34 using its configuration file. Execute a command to change
the permission to 7 for accessing the contents of file34 by user TOM.

Concept used:
1. Commands to create and manage users are as follows:
 useradd: Using this command, we can add users to the linux operating system.
Syntax: $useradd name_of_user
 su: It stands for super user.
Syntax: $su
 userdel: The user will be deleted with userdel command.
Syntax: $userdel name_of_user
 usermod: You can modify the properties of a user with the usermod command.
 Syntax: $usermod
 passwd: Passwords of users can be set with the passwd command. Users will have to provide
their old password before twice entering the new one.
Syntax: $passwd
2. Group Management Commands:
 groupadd: Groups can be created with the groupadd command.
Syntax: groupadd GroupName
 groups: A user can type the groups command to see a list of groups where the user belongs to.
Syntax: groups
 groupmod: You can change the group name with the groupmod command.
Syntax: groupmod newname oldname
 Groupdel: You can permanently remove a group with the groupdel command.
Syntax: groupdel GroupName

3. Controlling Access to Files with Access Control Lists (ACL)


 getfacl: /usr/bin/getfacl is a location from where the ACL’s can be read.
Syntax: $getfacl Filename
 setfacl: Writing or changing acls can be done with /usr/bin/setfacl.
Syntax: $setfacl -m u:USERNAME: PermissionOctalValue FileName
 chmod: This command is used to change the permissions. There are 3 types of users to whom 3 types of
permissions can be granted. 3 types of permissions are Read, Write and Execute 3 types of users are
Users, Groups and Others
 chgrp: It change the group owner of a file using the chgrp command.
Syntax: $chgrp GroupName FileName
 chown: The user owner of a file can be changed with chown command.
Syntax: $chown NewOwnerName FileName

Steps:
Ans.1.
i. create a user tom with user id 2211
- useradd -u 2211 tom (figure-1)
ii. set password of user as “redhat”
- passwd tom (figure-2)
iii. checking “/etc/passwd”
- cd /etc/
- tail -5 passwd (figure-3)

usernam password User Grou Home shell


e id p id directory

iv. checking “/etc/group”


- tail -5 group (figure-4)

Group password Group id Group list


name

v. adding tom to group “grp”


- groupadd grp
- usermod -a -G grp tom (figure-5)

Ans.2.
i. create file34 using vi command
-vi file34 (figure-6 and figure-7)

ii. command getfacl to get file access information


-getfacl file34 (figure-8)
iii. change the file owner “tom” and grant all file privileges
-chown tom file34
-setfacl -m u:tom:7 file34 (figure-9)

Results:
1.

Figure 1

Figure 2
Figure 3

Figure 4

Figure 5

2.

Figure 6

Figure 7
Figure 8

Figure 9

Learning outcomes:
1. Creating and managing users.
2. Creating and managing groups.
3. Accessing configuration files.
4. ACL commands to access files permissions.

You might also like