At the moment I'm working on a solution to prevent all admins users (except one particular) from running
sudo. I can add a specific user to sudoers by running:
echo '$username ALL=(ALL:ALL) ALL' >> /etc/sudoers
Then I'd like to remove
%admin ALL = (ALL) ALL within sudoers file which would just leave the above admin as the only sudo admin. However I cannot seem to find a way on how to remove/replace a particular string within sudoers.
I'd like to make this into a script hence using visudo and manually adjusting won't work for me. If there a way to run visudo from script and adjust a particular line within sudoers that would be ideal, but I couldn't find anything when researching on the Web.
I've seen a solution here:
which works in Linux. Is it possible to make it work in macOS?