sudo: /var/db/sudo/ts is owned by uid 501, should be 0 [duplicate]

I came from here and already fixed my sudoers: sudo: /etc/sudoers is owned by uid 501, should be 0

That allowed me to get sudo working. However, whenever I use sudo, I get a warning:

sudo: /var/db/sudo/ts is owned by uid 501, should be 0

how do I fix this?


UID 501 is the first administrator user on the machine, usually the first user that you create ergo you. Somehow ownership of the folder was set to you instead of root.

Open the terminal and change user to root:

# sudo su

Lets check the ownership of the files, first change dir to the folder:

# cd /var/db/sudo/

Then:

# ls -ln
total 0
drwx------  2 0  0  64 Oct 24 11:07 myusername
drwx------  3 0  0  96 Dec  5 08:23 ts

Another view:

# ls -la
total 0
drwx------   4 root  wheel   128 Sep 25 21:51 .
drwxr-xr-x  97 root  wheel  3104 Dec  5 07:57 ..
drwx------   2 root  wheel    64 Oct 24 11:07 myusername
drwx------   3 root  wheel    96 Dec  5 08:23 ts

You can see that on my system, both files are owned by true root user with UID 0. I would guess that changing the ownership of the folder should solve your problem. Still do make a copy of that folder beforehand.

sudo chown -R root:wheel /var/db/sudo/ts/

If you check the ownership again it should be user=root, group=wheel, so UID and GID 0.