For some reason my I can't run sudo, every time I try, I just get the error sudo: unable to open /var/db/sudo/ts/user: Invalid argument
The folder listed in the error (/private/var/db/sudo
) is completly empty, which explains why I can't run sudo, but how can I fix it, without sudo?
Things I already tried and other notes:
· Creating new (admin) account: still same error
· Both USB-ports are broken, so know backup of whole system possible (most important files still saved in cloud)
· I'm aware that I can reinstall OSX via ⌘+R or ⌘+⌥+R
Best Answer
Reinstalling the OS will fix /private/var and may well be needed. I’d start there, and test sudo again.
Next consider booting to single user mode and make a new admin user by removing one file only -
rm /var/db/.AppleSetupDone
Then you’ll know if sudo and your admin account and system are operational or you need to erase and start over to restore files from a backup.
Neither of the above steps will erase any files you have - just will correct system files and create a new user with clean admin permissions and home folder. That doesn't mean if your drive is failing, this won't erase everything or your drive is immune to failure - just that Apple macOS install doesn't erase any user data or settings - it's designed to upgrade everything in place and fix things. You have to jump through lots of hoops with warnings to erase and then install. A normal install is designed to be safe to your data.