Giving sudo privilege to a user
Background
There are some tasks in Linux that requires superuser (sudo) permission. For instance editing the /etc/fstab file, rebooting the system, mounting a drive, viewing /etc/passwd file and many other tasks cannot be done without sudo privilege.
What this documentation will help achieve
This documentation helps you to give sudo privilege to a user.
Prerequisites
- TU Delft netID
- Basic knowledge of Linux
- Those who grant sudo permission need to have sudo permission themselves.
Tools/Software
- For Windows users, you will need a programming and runtime environment like Cygwin or SSH client like PuTTY in order to access the VPS running Linux.
Steps
- Getting the username(s) of sudo access candidates
- Navigating to the sudoers directory
- Create an access file for each of the candidates
- Editing the access files
Step 1. Getting the username(s) of sudo access candidates
You can get the usernames by checking the /etc/passwd
file. This file contains all the usernames and their login information.
Step 3. Create an access file for each of the candidates
If you use ls
command to check the available files in this folder, you can see there are some files that their name start with a number and then a dash and then a user name (<number>-<username>
). In Linux for every user with a sudo permission, there is a file like that, so we duplicate one of the existing files and rename them for each of the sudo candidates (in fact, name of those file doesn’t matter; however, it helps us to understand which users have sudo privilege without opening them).
Step 4. Editing the access files
In this step you need to open each of the newly duplicated files and replace the old username in the second line with the sudo candidate username. After the edit, you just save the changes and exit the file.