Assign password to Users & Groups in Linux

Hello, everyone In this Article we are going to learn how to assign a password to users and groups in Linux in a very simple and easy step-by-step approach.

Yellow Fishing Boat Blog Banner 82

Assign password to Users & Groups in Linux

When we create a user in Linux as if we don’t assign the password of that user then that user will not able to login in server without the password.

Please note that the root account has the rights that they can log in to a normal user account without any password.

If a normal user wants to switch to another normal user then again it will ask for the password to log in to another account.

Password is very important for every Linux user we have to assign a password to every user in the Linux system in order to switch between the users and do the related tasks.

1 How to assign Password for the user

To assign the password for the user we can use passwd command with the username.

# passwd devopstutuser
Screenshot 1 2

2. How to check whether the password is assigned or not

To know that whether the password is assigned to the user or not then we can use the ( -S ) option with the passwd command and the username

# passwd -S user1
Screenshot 2 2

3. How to lock the password for the user

To lock the password of user1 then we can user ( -l ) option.

Only a user1 is blocked from login in to a Linux server but the root user can able to go into the normal user account.

Screenshot 3 3

4. How to Unlock the password for the user

To unlock the password of user1 then we can user ( -u ) option with passwd command and the username.

# passwd -u user1
Screenshot 4 3

5 . How to make the user passwordless

If we add ( -d ) option is used to delete the password.

Now when a normal user wants to go into user1 account that will not ask for user1 account password

# passwd -d user1
Screenshot 5 3


6 How to assign a password for Group

To assign the password to the group then we can use the gpasswd command.

# gpasswd devopstutgroup
Screenshot 6 3

7 How to delete a password for Group

To delete the password to the group then we can use the gpasswd command with ( -r ) option.

# gpasswd -r devopstutgroup
Screenshot 7 3

Conclusion

This is the complete article on how we can assign the password to users and groups.

If you want to learn Linux in the most simple language then please click on this link.

If you want to know the manual page for passwd command online then click on this link

If you want to know the manual page for gpasswd command online then click on this link

This is the complete knowledge of how we can assign the passwords in Linux if you have any doubts please feel free to comment below. Please don’t forget to join our email subscription to get the latest updates on DevOps Articles.

Leave a Comment