How do I restore admin rights after changing username on MacBook Air?

I changed my username and lost my admin rights. I can't restore them. I delete the AppleSetupDone file through recovery mode and when I turn on the computer, it is back in its place and there is no way to create a new admin. Here is the instruction I use to do everything step by step: https://www.howtoisolve.com/no-admin-account-on-mac/

When I turn on the Mac, nothing happens. If I try to find the AppleSetupDone file again, it is in its place, even if it was previously deleted.



[Re-Titled by Moderator]

MacBook Air 13″

Posted on Feb 26, 2025 9:36 PM

Reply
5 replies
Sort By: 

Feb 27, 2025 2:25 AM in response to darserg

There is a Right Way to change the User Account Name ( Admin Account )


There is a Wrong Way to change the User Account Name ( Admin Account )


If you Change the User Account Name and forget to Change the User Account " Home Folder " name - ouch


Change the name of your macOS user account and home folder


Not sure if this computer is an Apple Silicon M1, M2 etc computer


But if some there is a new concept introduced on Apple Silicon Computers call " Owner " or " Ownership"


Below link will provide additional insights about the Difference between Admin Accounts and Owner Accounts  


https://eclecticlight.co/2021/07/18/last-week-on-my-mac-the-perils-of-m1-ownership/


Reply

Feb 27, 2025 9:30 AM in response to Barney-15E

Barney-15E wrote:

As of Sonoma, that method no longer works. You must erase and reinstall. However, here is a method that might work: Restoring Lost Administrator on macOS Son… - Apple Community

Interesting. I wish the author of that post would have had the changes placed into the "/etc/sudoers.d" folder instead as it is much less risky if something is typed incorrectly.

Reply

Feb 27, 2025 7:09 PM in response to Barney-15E

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.

Reply

How do I restore admin rights after changing username on MacBook Air?

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