![]() 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. ![]() 3 Ask for the sudo password for a specific command in the sudoers fileĮxecute specific commands without sudo password in Ubuntu.2 Find the path to the command and add it to the sudoers file.1 Execute specific commands without sudo password in Ubuntu.With no password, but it still asks for a password for the account I am logged in as. Now, for "good measure" I have started sshd again, and logged back in as keithchegwin fully expecting to be able to do: su root What I have done is logged in as root (Which DOES require my account password) and then: visudoĪnd added this line here for the account for "Keith". Once I have logged in, with my account, I want to be able to sudo to root without a password. I am accessing my machine via passwordless ssh with a key that requires a passphrase. In an attempt to be able to ssh to an account, and then get to root without having to use a password. I have used various instructional documents, such as the below:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |