How to add a new user with sudo rights

Let’s say you have a new user needing sudo access to a Linux server. How do you grant him/her this great privilege? First, explain to the new user that sudo rights allow to do pretty much anything on a Linux machine – including screwing everything up! – and that with greater power also comes greater responsibilities. Then, follow this procedure:
- Create a new user (e.g. newusername) and add it to group wheel (members of this group have sudo rights):
sudo useradd -G wheel newusername - Set up the password for the new user. First, login as root:
Then set the password for the new user (e.g. newusername):
sudo -iFinally exit from root with:passwd newusernameexit - Test the newly created user and password by logging in as user newusername:
su - newusername - Test that the newly created user is in group wheel:
groups newusername