5

From "Do we need to reboot after adding an user to sudoers?", it is apparent that restarting Sudo Service is necessary, or reboot. However the recommended way, which works for Ubuntu 14.04, is no longer working for Ubuntu 18+:

$ sudo service sudo restart
Failed to restart sudo.service: Unit sudo.service is masked.

Solution?

xpt
  • 1,045

2 Answers2

8

masked services are when the systemd unit files are linked to /dev/null/ You can see the sudo.service

$ systemctl status sudo.service
● sudo.service
   Loaded: masked (/dev/null; bad)
   Active: inactive (dead)

$ ls -l /lib/systemd/system/sudo.service
lrwxrwxrwx 1 root root 9 Jan 18  2018 /lib/systemd/system/sudo.service -> /dev/null

Some services are used within systemd, and not actual daemons with processes that run in the background. For example, you cannot start/stop halt.service. But if you place your scripts in /usr/lib/systemd/system-shutdown/, they will be run before the system is halted or rebooted.

Sudo Usage

You don't need to reboot to use sudo. Simply add users and your settings to the Sudoers file.

hanxue
  • 690
  • 1
    Thanks for the reply, although I don't quite understand most of it except for the conclusion "You don't need to reboot to use sudo". It might be true for adding users, but from the quoted question, and for my case, https://askubuntu.com/questions/1164220/, not restarting Sudo Service doesn't have any effect. – xpt Aug 08 '19 at 11:55
  • 1
    What I'm trying to say is that sudo.service is not a "real" service. There isn't any sudo process or daemon running in the background, and you need to restart it to pick up changes to the sudoers file. Ah, I see what you are getting. The other question is clearer on what you are trying to achieve. – hanxue Aug 08 '19 at 12:25
0

I know it's late but I wanted to give my two cents to newbs like me. I also thought the change wasn't working, it was just silly of me that I thought you didn't need to type sudo anymore after the first one for however long timeout in sudoers is set for (default 15 min). In other words you have to keep typing sudo before any relevant command, it just doesn't ask you for password anymore.

Eliah Kagan
  • 117,780