Lab 6

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Lab Experiment - 6

AIM To learn how to manage local users and groups in a Linux


system

creating, modifying, and deleting users and groups,


Description
managing user permissions, and configuring password
policies

Pre-Lab
useradd, passwd, userdel, usermod, chage, chgrp, touch
Commands

1. Create a new user named user1. Set a password for user1.


Verify the creation of user1 by checking the /etc/passwd
file. Delete the user user1.
2. Create a new group named group1. Add the existing user
In Lab user1 to group1. Verify the addition of user1 to group1 by
checking the /etc/group file. Delete the group group1.
3. Change the home directory of user1 to /home/newuser1.
Change the
login shell of user1 to /bin/bash. Change the full name of user1
to "User One". Verify the changes by checking the /etc/passwd
file.

What command is used to create a new user


in Linux? How do you create a new group in
Viva Questions
Linux?
What command is used to modify user account
details? What command is used to configure
password aging policies?

1. Set the minimum password age for user1 to 7 days. Set the
maximum password age for user1 to 90 days. Set a password
Post Lab
expiration warning for user1 to 7 days. Verify the password
aging settings.
1. Create a New User (user1)

 Create user1:

sudo useradd user1

 Set a password for user1:

sudo passwd user1

 Verify creation by checking the /etc/passwd file:

grep 'user1' /etc/passwd

 Delete the user user1:

sudo userdel user1

2. Create a New Group (group1) and Add user1 to it

 Create group1:

sudo groupadd group1

 Add user1 to group1:

sudo usermod -aG group1 user1

 Verify the addition by checking the /etc/group file:

grep 'group1' /etc/group

 Delete the group group1:

sudo groupdel group1

3. Modify User Information

 Change the home directory of user1 to /home/newuser1:

sudo usermod -d /home/newuser1 -m user1

The -m option moves the content from the old home directory to the new one.

 Change the login shell of user1 to /bin/bash:

sudo usermod -s /bin/bash user1

 Change the full name of user1 to "User One":

sudo usermod -c "User One" user1

 Verify the changes by checking the /etc/passwd file:

grep 'user1' /etc/passwd

This set of commands will help you manage users and groups effectively in a
RHEL/CentOS system.
1. Set the minimum password age for user1 to 7 days. Set the
maximum password age for user1 to 90 days. Set a password
Post Lab
expiration warning for user1 to 7 days. Verify the password
aging settings.

sudo chage --list user1

Set the maximum password age for user1 to 90 days

chage -M 90 username

the minimum password age for user1 to 7 days

chage -m 90 username

Set a password expiration warning for user1 to 7 days

Sudo chage username

Passwd user1

Cat /etc/passwd

This will set the number of days in advance the user will begin receiving
warnings that the password will expire.

For example:

# passwd -w 7 user2

To force a user to change their password upon next login

sudo chage -d 0 <username>

Use the vi /etc/login.defs file to set password aging policies.

You might also like