Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Admin account does not have sudo

I have a work laptop, and I recently suddenly lost `sudo` access even I am an admin on my laptop.


I originally found the thread at https://discussions.apple.com/thread/7654548

However, my UUID is inside of Directory Utility -> Directory Editor -> Administrators -> GroupMembers


I got many issues such as


> brew install hyperkit
Error: The following directories are not writable by your user:
/usr/local/share/zsh
/usr/local/share/zsh/site-functions

You should change the ownership of these directories to your user.
sudo chown -R $(whoami) /usr/local/share/zsh /usr/local/share/zsh/site-functions

And make sure that your user has write permission.
chmod u+w /usr/local/share/zsh /usr/local/share/zsh/site-functions

> visudo
visudo: /etc/sudoers: Permission denied

> sudo -l -U homiao
Password:
Sorry, user homiao is not allowed to execute 'list' as homiao on LUSC02F40QRMxxx.



MacBook Pro (2020 and later)

Posted on Dec 6, 2021 3:02 PM

Reply
Question marked as Best reply

Posted on Dec 6, 2021 3:02 PM

I tried many solutions online, and finally found the solution which is at https://apple.stackexchange.com/a/391525/151276


Here is a copy:


This worked for me: (No root password, but admin access required)

1. Created another admin account test
2. Manually set it's uid to 0 (right click on account > Advanced Options)
3. Restart the system, login via test (a lot of errors will pop-up, cancel/ok all of them)
4. Go to `cd /etc/` and `chown -R $(whoami) sudoers` (The sudo error will go away now, but to remove test account, we have to undo everything)
5. Restart the system and login with your normal account
6. Manually set test uid to 502 (or 500+something that is not taken by other admins)
7. Remove the test account


Hopefully helps someone who met same issue in the future!

Similar questions

1 reply
Question marked as Best reply

Dec 6, 2021 3:02 PM in response to Hongbo Miao

I tried many solutions online, and finally found the solution which is at https://apple.stackexchange.com/a/391525/151276


Here is a copy:


This worked for me: (No root password, but admin access required)

1. Created another admin account test
2. Manually set it's uid to 0 (right click on account > Advanced Options)
3. Restart the system, login via test (a lot of errors will pop-up, cancel/ok all of them)
4. Go to `cd /etc/` and `chown -R $(whoami) sudoers` (The sudo error will go away now, but to remove test account, we have to undo everything)
5. Restart the system and login with your normal account
6. Manually set test uid to 502 (or 500+something that is not taken by other admins)
7. Remove the test account


Hopefully helps someone who met same issue in the future!

Admin account does not have sudo

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.