Introduction to users and groups in Linux. We will explore how to set user expiry information and force user password change after certain period of time. We will be also providing different permission to users and groups and restricting users and groups operations using sudoers file
2. Lack of etiquette and manners is a huge turn off.
KnolX Etiquettes
Punctuality
Join the session 5 minutes prior to
the session start time. We start on
time and conclude on time!
Feedback
Make sure to submit a constructive
feedback for all sessions as it is
very helpful for the presenter.
Silent Mode
Keep your mobile devices in silent
mode, feel free to move out of
session in case you need to attend
an urgent call.
Avoid Disturbance
Avoid unwanted chit chat during
the session.
3. Agenda
01 Users: Creating, Deleting
02 Modifying user details and expiry
03 Groups: Creating, Deleting
04 System wide environment
05 sudo command and Managing user and group permission using sudoers file
4. Users
● A user is an entity, in a Linux operating system, that can manipulate
files and perform several other operations. Each user is assigned an
ID that is unique for each user in the operating system. (/etc/passwd
directory)
● Creating and deleting user :- useradd and userdel
● Creating users with default and custom home directory (/etc/skel
directory)
● System User accounts :- Accounts with UID less than 1000 and used
by daemons
● Set UID and GID for users
● Setting password and logging in to a user
5. Modifying user details and Expiry
● Change home directory of an user
● Change username and shell of an user
● Change defaults of useradd command
● chage command -
○ Set the max number of days after password change when
password expires
○ Setup warning for user to change password
○ Lock inactive accounts
○ Set Account expiry date
○ Set minimum number of days after which password can be
changed
6. Groups
● User groups play an important role on Linux systems. They provide
an easy way for a select groups of users to share files with each
other. They also allow sysadmins to more effectively manage user
privileges, since they can assign privileges to groups rather than
individual users. (/etc/group directory)
● Creating and deleting group :- groupadd, groupdel
● Add and remove user to and from a group
● Primary and Secondary groups:
○ Primary group – Specifies a group that the operating system
assigns to files that are created by the user. Each user must
belong to a primary group.
○ Secondary groups – Specifies one or more groups to which a user
also belongs. Users can belong to up to 15 secondary groups.
7. Groups
● Changing primary and secondary group of users.
● Creating users with specific primary and secondary groups
● Changing group name
● Deleting users from groups with new gained knowledge of primary
and secondary groups
8. System Wide environment
● Setting environment variables specific to an user
● Setting environment variables for all users (/etc/environment file)
● Using /etc/profile.d to create not so simple scripts that needs to be
executed every time any user opens a login shell to set any variable
or any profile
● Setting user specific profile using .bash_profile, .bash_login, .profile
9. sudo command and sudoers file
● sudo: Command to execute command as any other user (sudo -i and
sudo -u <command>)
● Editing /etc/sudoers file using visudo command
● sudoers file syntax:
○ User/group
○ Host based on which rules will be executed
○ Users and groups which can be used to execute the commands
○ Commands that can be executed
● Only root user can run sbin binaries
10. Cheatsheet
Command Description
useradd Command to create an user
usermod Command to modify user details
userdel Command to delete user
groupadd Command to create a group
groupdel Command to delete a group
gpasswd Command to add and remove user to and from a group
sudo Execute command as another user
su Switch user
chage Manage user account and password lifecycle
visudo Command to edit sudoers file(/etc/sudoers)
/etc/skel Directory from which new home directory is copied
/etc/environment System wide environment file
/etc/passwd File holds user details
/etc/profile.d Directory holds script that are execute on every user login
/etc/sudoers Sudoers file
11. Thank You !
Get in touch with us:
Lorem Studio, Lord Building
D4456, LA, USA