How do I remove the password for sudo commands?

I've set up two commands that enable and disable my keyboard so I can set things on top of it and still use the screen. However, the commands require the sudo password. According to what I've read, I need to edit the Sudoers file using the "sudo visudo" command in terminal. I've figured out how to open in, but I'm having trouble figuring out how to edit it. I changed "%admin ALL=(ALL) ALL" to "%admin ALL=(ALL) ALL NOPASSWD: ALL" but I can't figure out how to save the file.

MacBook Pro 13", macOS 10.15

Posted on Nov 20, 2019 10:30 PM

Reply
Question marked as Top-ranking reply

Posted on Nov 21, 2019 1:22 PM

It is a modified vi window, which means :wq will save the file and exit the program.


You might also want to look at https://askubuntu.com/questions/100051/why-is-sudoers-nopasswd-option-not-working


However, a better solution is to use the setuid flag https://linuxconfig.org/how-to-use-special-permissions-the-setuid-setgid-and-sticky-bits


If you write a shell script set the owner and group to root, it will be executed with the privileges that would occur if the script was executed by root. You can then put tests in the script so that it will only run if you run it. This doesn't create the security hole that you would create by removing the password from the sudo command.

1 reply
Question marked as Top-ranking reply

Nov 21, 2019 1:22 PM in response to petersFXfilms

It is a modified vi window, which means :wq will save the file and exit the program.


You might also want to look at https://askubuntu.com/questions/100051/why-is-sudoers-nopasswd-option-not-working


However, a better solution is to use the setuid flag https://linuxconfig.org/how-to-use-special-permissions-the-setuid-setgid-and-sticky-bits


If you write a shell script set the owner and group to root, it will be executed with the privileges that would occur if the script was executed by root. You can then put tests in the script so that it will only run if you run it. This doesn't create the security hole that you would create by removing the password from the sudo command.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How do I remove the password for sudo commands?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.