EDIT
I ran the following:
$ echo $USER
goldy
$ hostname
goldy-ThinkPad-X1-Carbon-6th
$ sudo visudo -f /etc/sudoers.d/kill
and added goldy goldy-ThinkPad-X1-Carbon-6th = (root) NOPASSWD: /bin/kill
And tried rebooting. Still what I run kill
I'm asked for a password.
Tho I notice this:
$ sudo cat /etc/sudoers | grep includedir
#includedir /etc/sudoers.d
I didn't want to remove #
without being sure I'm not screwing anything up :)
Is that the missing step?
Because It seems like that directory should be included by default:
$ sudo cat /etc/sudoers.d/README
# As of Debian version 1.7.2p1-1, the default /etc/sudoers file created on
# installation of the package now includes the directive:
#
# #includedir /etc/sudoers.d
OP
I have the following shell function to kill a port
function kill-port {
PORT=$1
sudo kill -9 $(sudo lsof -t -i:$PORT)
}
How can I run it w/o the need to input a password?
I've seen here how to use pkill
w/o password, how do I do the same for kill
?
sudo
. That's intentionally done that way, you need to usesudo
to terminate the process if it's not owned by you. – Thomas Ward Aug 13 '21 at 02:13pkill
to a user, so why notkill
? – goldylucks Aug 13 '21 at 06:02kill
as the user, they still need to call it withsudo
to work. – Thomas Ward Aug 13 '21 at 18:29sudo kill
andsudo lsof
. Who's going to add the NOPASSWD rule forlsof
? – muru Aug 15 '21 at 07:15