How to add a user to the sudoers file to allow them to use the sudo command.
The /etc/sudoers file contains definitions of all the users that are allowed to use superuser privileges on Linux to perform various tasks as an administrator.
This is how to add a user to this file to allow them superuser privileges. Firstly; you must edit this file with the visudo command. This makes sure that the file is in the correct syntax and there are no errors.
Add the user thusly. Type su -c “visudo” and then add this line to the sudoers file.
user1 ALL=(ALL) ALL
This will add the user user1 to the suoders file and he/she will be able to run commands as a superuser.
The sudoers file is owned by the root user; therefore you will not be able to view it as a normal user.
homer@hal9000:/etc$ cat sudoers cat: sudoers: Permission denied
If you add this to your /etc/sudoers file with visudo; then you will be able to run a single command without being asked for a password. This is for the user “homer”.
Cmnd_Alias UMOUNT=/bin/umount homer ALL=NOPASSWD: UMOUNT