0% found this document useful (0 votes)
25 views

Manual of The Experiment 1.4

The document discusses user and session management commands in Linux. It covers commands for creating and managing users and groups like useradd, userdel, groupadd, passwd. It also covers controlling file access using ACLs with commands like chmod, chgrp, chown and getfacl, setfacl.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

Manual of The Experiment 1.4

The document discusses user and session management commands in Linux. It covers commands for creating and managing users and groups like useradd, userdel, groupadd, passwd. It also covers controlling file access using ACLs with commands like chmod, chgrp, chown and getfacl, setfacl.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Practical-4

Manual

In this practical, we all are going to discuss the user and session management commands. As
the name suggests, these all commands will be related to creating users, removing users and
managing their sessions. Along with user management, we will also learn about the group
management commands. So, let's start with the commands for managing users and their
sessions.

a. Creating and managing users and groups using useradd, userdel, groupadd and
passwd:

Fig-1 User Management [1]

Users can be created in 3 different ways. First, by using graphical user interface, second,
command line tools, third, edit the local configuration files. We are going to discuss the
Second way here i.e. by using command line tools. So, the commands to create and manage
users are as follows:
1. useradd: Using this command, we can add users to the linux operating system.
Syntax: $useradd name_of_user
Output:
2. su: It stands for super user.
Syntax: $su
Output:

3. userdel: The user will be deleted with userdel command.


Syntax: $userdel name_of_user
Output:

4. usermod: You can modify the properties of a user with the usermod command.
Syntax: $usermod
Output:

5. 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
Output:

Note: Configuration file, where the information about the users is placed is /etc/passwd.

Fig-2 /etc/passwd file content [2]

Group Management Commands:

1. groupadd: Groups can be created with the groupadd command.


Syntax: groupadd GroupName
Output:
2. groups: A user can type the groups command to see a list of groups where the user
belongs to.
Syntax: groups
Output:

3. groupmod: You can change the group name with the groupmod command.
Syntax: groupmod newname oldname
Output:

4. Groupdel: You can permanently remove a group with the groupdel command.
Syntax: groupdel GroupName
Output:

Note: Configuration file, where the information about the groups are placed is /etc/group.

(b) Controlling Access to Files with Access Control Lists (ACL) using chmod, chgrp and
chown

Access Control Lists came to existence in order to protect files and directories, File systems
supporting access control lists, or acls, have to be mounted with the acl option listed in
/etc/fstab.

1. getfacl: /usr/bin/getfacl is a location from where the ACL’s can be read.


Syntax: $getfacl Filename
Output:
2. setfacl: Writing or changing acls can be done with /usr/bin/setfacl.
Syntax: $setfacl -m u:USERNAME: PermissionOctalValue FileName
Output:

3. 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

Fig-3 chmod Permissions [3]

Syntax: $chmod (user type)=(Permission Type) FileName


Example: chmod u=rwx,g=rx,o=r myfile
Output: rwxr-xr-- hope hopestaff 123 Feb 03 15:36 myfile

4. chgrp: It change the group owner of a file using the chgrp command.
Syntax: $chgrp GroupName FileName
Output: chgrp hope file.txt
It will Change the owning group of the file file.txt to the group named hope.

5. chown: The user owner of a file can be changed with chown command.
Syntax: $chown NewOwnerName FileName
Output: sudo chown myuser myfile.txt
This command will change the owner of file myfile.txt to myuser

References:

1. https://www.computernetworkingnotes.com/rhce-study-guide/linux-group-
management-explained-with-examples.html
2. https://devconnected.com/how-to-list-users-and-groups-on-linux/
3. http://www.yourownlinux.com/2013/09/chmod-basics-of-filesdirectories.html

You might also like