DEV Community

Discussion on: make sudo not ask for password

moopet profile image
Ben Sinclair

"make sudo not ask for password" is the post title, and that's not what it's about.

A similar example could be "visit the shops and cafes without wearing a mask" but the post turns out to be about using Amazon to get things delivered. Similar, but critically different.

the good thing is when you close the terminal and open a new terminal , the new one will be normal as before without the need to undo the change in any files

sudo doesn't need you to exit the session. It has a number of benefits, such as auditing who ran a command and being able to see in your history what you ran as root. You also don't need to close the terminal to exit from su, you can type exit or hit ctrl-D to log out of that session.

so using sudo su and then running the script will not make you type the password until you exit out of that terminal

sudo (by default) doesn't prompt you every time for your credentials, it prompts you after five minutes of inactivity. Another thing you could do, if you really wanted to bypass securty, is to use setuid to make your script run as root regardless of who ran it. Then you wouldn't ever need to put in your password at all.