I had updated my sudoers
file to make some command run with root privileges by default without the need to use sudo
and entering my password. I used the command sudo visudo
and added this line to it:
<my_username> ALL=(ALL) NOPASSWD: <path/to/command --arguments>
But whenever I update macOS, my sudoers
file is reset to its defaults. A folder named Relocated Items
appears on my Desktop and it always includes the following file: /Users/Shared/Relocated Items/Configuration/private/etc/sudoers
. This happens on macOS Catalina, and also on macOS Big Sur.
How can I prevent the sudoers
file resetting to its defaults with every macOS update?
/etc/sudoers
, but add a file to/etc/sudoers.d
instead.sudoers
is configured to read files in that path and apply any rules defined in them. I'd recommend that you name files in/etc/sudoers.d
after the user they apply to, for example, if your username isbehdad
,/etc/sudoers.d/behdad
. You can create the file withsudo visudo -f /etc/sudoers.d/behdad
.sudoers
touched in any way.pkg
file downloaded from Apple Support website. I sometimes update using Software Update in System Preferences. In short, I don't do a clean install.