Barney-15E wrote:
I was gonna make a user tip out of it, but never got around to it, and I certainly don’t have the knowledge about the sudoers file as you do.
I don't have that great of knowledge with it either as I've only modified it a couple of times over the years. A person must be extremely careful with the entries so as to limit any extra privileges to as narrow a footprint as possible to limit the scope (the entry proposed in that linked article is just specifying the specific user has the same privileges as any existing "admin" user, but of course this person would be a hidden "admin" if this was not just a single user system). I never realized it was possible to place the edits into the "sudoers.d" folder at first, but after modifying the GRUB2 bootloader on Linux where they had a "grub.d" folder where modifications should reside, a light bulb went off when I saw the "sudoers.d" folder.
You just need to use the " -f <path-file-name>" option when invoking "visudo" so it will save the specified file and perform the same checks as it would do to the main "sudoers" file. You can use "man visudo" as a reference as well as "man sudoers". A good name would be something like "/etc/sudoers.d/hwtech_admin"
Of course I would suggest using "nano" as the editor (actually on macOS it is "pico") since it is a bit more user friendly than the default "vim" as used in the linked article, but the post did explain how to save the changes & exit. To use "nano" instead, you just need to modify the EDITOR variable by pre-pending it to the command:
EDITOR=nano sudo visudo -f /etc/sudoers.d/<your-file-name>
And it would be a good idea to have the user go into the Users & Groups System Settings to re-enable that user as an "Admin" again followed by deleting the file with the sudoers changes. If the user is not actually part of the "admin" group, then it may break some other things on macOS. On a single user system this isn't such a big deal, but I'm always one that prefers to minimize such customizations since the user will inevitably forget about it down the road.