In this tutorial, I will quickly guide create user and group in Linux. How to add a user to a group in Linux. How to create users has permission or user no has permission.
Using command to create the and command to create the in Linux system.
How to create user and group in Linux
create group new in Linux
use groupadd command as below
$ sudo groupadd -g 2000 common # group common no has sudo permission
$ sudo groupadd -g 2001 dev # group dev has sudo permission
$ sudo groupadd -g 1100 IT
Create user new in Linux
For example, user user01 no has permission and user has permission
# useradd -m -d /home/user01 -s /bin/bash -g common -u 5000 user01; echo -e "user01\nuser01\n" | passwd user01
# useradd -m -d /home/huupv -s /bin/bash -g IT -G dev -u 5001 huupv; echo -e "huupv\nhuupv\n" | passwd huupv
Add group to sudoers file
use visudo to open and edit the /etc/sudoers file and add group dev as follow below
%dev ALL=(root) ALL
Option
Create a user with sudo without password Linux.
# useradd -d /home/devops -u 8888 -s /bin/bash
# echo -e "devops\ndevops\n" | passwd devops
# echo "devops ALL = (root) NOPASSWD:ALL" | tee /etc/sudoers.d/devops
# chmod 0440 /etc/sudoers.d/devops
Conclusion
Through the article, You can create user and group in Linux as above. I hope will this your helpful. Thank you for reading the DevopsRoles page!
