Linux create user

In this tutorial, I will guide use useradd create user in linux. The memo complete linux create user and how to user run sudo command with no password.

Create user with useradd command

Create User test with option:
Specific user ID: -u 1234
Specific Group ID: -g 1002
Specific a Group IT and vboxusers: -G IT,vboxusers
Specific bash shell: -s /bin/bash
Specific the directory: -d /home/test
Specific password: Whoami12345678

Running useradd command as below:
sudo useradd test -d /home/test -s /bin/bash -u 1234 -g 1002 -G IT,vboxusers  ; echo -e "Whoami12345678\nWhoami12345678\n" | sudo passwd test

Use id command verify
[[email protected] ~]$ id test
uid=1234(test) gid=1002(IT) groups=1002(IT),981(vboxusers)

User run sudo command with no password
[[email protected] ~]$ echo "test ALL=(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers

To check
[[email protected] ~]$ sudo visudo -c

Verify, you can run sudo without a password
[[email protected] ~]$ sudo cat /etc/hosts

The result, Linux create user

Linux create user

No comments:

Post a Comment