- At the command line prompt, type su and press Enter. You will then be prompted for the root password, so enter it and press Enter.
You should end up with a different looking
prompt, often ending with ‘#’. For example:$ su
Password:
# - Now, you need to create a configuration file to enable your user account to use sudo. Typically, this file is created in the /etc/sudoers.d/ directory with the name of the file the same as your username. For example, for this demo, let’s say your username is student. After doing step 1, you would then create the configuration file for student by doing this: # echo "student ALL=(ALL) ALL" > /etc/sudoers.d/student
- Finally, some Linux distributions will complain if you do not also change permissions on the file by doing: # chmod 440 /etc/sudoers.d/student
- To enable sudo without password# echo "student ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/student