I'm running some scripts to check the UFW status and would like to run sudo ufw status without having to do sudo. I was hoping to find a firewall or ufw group to add myself to, but I didn't find any.
How can I allow any user X to do the ufw status without being root or asking for sudo password?
UPDATE:
I wanted to try to add my own file to /etc/sudoers.d/, but was lazy so decided to copy one already existing, like this:
sudo cp /etc/sudoers.d/mintupdate /etc/sudoers.d/firewall_status
Don't do That! You will not be able to do sudo or login again. I had to do a boot recovery. Instead use:
sudo visudo -f /etc/sudoers.d/ufwstatus
Now just follow the accepted answer below.
sudo ufw ...without password? I doubt that running firewall things without root privilege will work. – Thomas Feb 10 '19 at 14:17chmod 777, then I'd rather say no, as any user could disable the FW. I'm looking for a proper solution to add people to groups or add specific users/execs to some sudoers list. – not2qubit Feb 10 '19 at 14:53sudo- simplyservice ufw status– waltinator Feb 10 '19 at 15:28ufw statuslists the ruleset – steeldriver Feb 10 '19 at 15:31ufw, they also have the ability to turn off the firewall. – Charles Green Feb 10 '19 at 15:40visudofor editing the sudoers files.... – Charles Green Feb 10 '19 at 15:43chmodbut rather runsudo ufw ...without providing a password. You could lock down that to a group or user as linked by Charles Green. – Thomas Feb 10 '19 at 16:29/etc/sudoerswithCmnd_Alias FWSTAT = /usr/sbin/ufwandxxxx ALL=NOPASSWD: FWSTAT. But I'm still asked to provide password... – not2qubit Feb 10 '19 at 18:52