![]() # This file MUST be edited with the 'visudo' command as root. %LimitedAdmins ALL=NOPASSWD: /bin/systemctl/unicorn_ofn_america restart, /bin/systemctl/unicorn_ofn_america startĬontent of /etc/sudoers/ is the default as confirmed with sudo visudo (or sudo cat /etc/sudoers): # %LimitedAdmins ALL=NOPASSWD: /etc/init.d/unicorn_ofn_america restart, /etc/init.d/unicorn_ofn_america start Have followed the instructions here to add user ubuntu to a newly created group, LimitedAdmins, which is confirmed with: $ getent group LimitedAdminsĬreated a new file, limitedadmins (using sudo vim) in the /etc/sudoers.d directory containing the following text: Specifically systemctl restart unicorn_my_app.service. However, you will have to type it when you want to run the command ' apt'.I want the default user, ubuntu to be able to run a specific service without being prompted for a password. In this case, the user entreunosyceros can execute the commands' mkdir'Y' chmod'without typing the sudo password. Following the example, we are going to modify the line added to the sudoers file as shown below:Įntreunosyceros ALL=NOPASSWD:/bin/mkdir,/bin/chmod,PASSWD:/usr/bin/apt Save the file, log out, and log back in.Īn alternative would be add the directive 'PASSWD:' in front of the command that we want it to need to write the sudo password. If after doing so, if you need the user to have to type the password again, all you have to do is edit the sudoers file and remove the added command. Sudo apt update Ask for the sudo password for a specific command in the sudoers file Now, it can be verified if the user can execute the command with the sudo prefix without using the password: Inside it would be add the command 'apt' in the file as we did with the previous commands:Įntreunosyceros ALL=NOPASSWD:/bin/mkdir,/bin/chmod,/usr/bin/aptĪfter adding the command, save and close the sudoers file. In case we are interested in not having to type the password for sudo when executing the apt command, we will have to edit the sudoers file again: sudo visudo In the terminal (Ctrl + Alt + T) you would have to write:Īs you can see in the screenshot above, the path for the apt command is / usr / bin / apt, therefore this is the path to add in the sudoers file. In case of not being sure of it, we can use the command ' where's'to find out the correct path to apt. In this case we want to add a command with a different path than the one we have used so far, the path to apt for example, we will need to correctly write the path to the executable file. Find the path to the command and add it to the sudoers file Yes indeed, when running all other commands, if you will be prompted to enter the password to use sudo. From now on, the user referred to by the line added to the file sweats you will not need to enter the sudo password while executing any of the added commands. We will be able add as many commands as we want separating them with commas, as it's shown in the following:Įntreunosyceros ALL=NOPASSWD:/bin/mkdir,/bin/chmodĪfter finishing adding the line, log out and log in again or reboot the system. According to this line, this user will be able to execute the command ' mkdir'without typing the sudo password. ![]() In this line that is added in the previous capture, entreunosyceros is the username. When the file is opened, at the end of it we will add the following line: In the terminal (Ctrl + Alt + T) we write: sudo visudo To do this, we will have to edit the sudoers. Let's say we want a user named interunosyceros run the mkdir command without having to type the sudo password. If for any reason, whatever it may be, you are interested in allowing a user to execute a particular command without having to type the sudo password, you should add that command to the sudoers file.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |