5

I wanted to change the name of my user as well as its home directory. Looking for a way to do this, I stumbled upon this support document.

I did everything as described there, but since I restarted the computer, all that happened is, that I'm not an admin anymore.

I can't unlock anything under System Preferences > Users & Groups, as well as I'm unable to edit /etc/sudoers/

What went wrong? whoami still shows my previous username..

How can I fix this mess? Am I screwed now?

macOS 10.13.4 btw

0

2 Answers 2

7

From I don't have administrator account on my mac

  1. Boot into Single User Mode: Start/restart your Mac. As soon as you hear the startup tone, press and hold + S until you see a black screen with white lettering. (If you end up back on the login screen after a flash of the black screen with white lettering, enter your password and it will return to the black screen.)

  2. Mount the drive by typing /sbin/mount -uw / then ↩ enter.

  3. Remove the Apple Setup Done file by typing rm /var/db/.AppleSetupDone then ↩ enter.

  4. Reboot by typing reboot then ↩ enter.

  5. Complete the setup process, creating a new admin account.

This should allow you to create a new admin user.

1
  • 2
    Starting in macOS Catalina (10.15), macOS uses a split volume format, which complicates this procedure. Change the mount command to mount -uw /System/Volumes/Data, and the rm command to rm /System/Volumes/Data/private/var/db/.AppleSetupDone. Also, some newer Macs disallow Single-User mode, so you have to use Recovery mode (with different commands) instead (see my comments at this question). Commented Apr 16, 2021 at 21:45
-1

Another way is:

First write the command on terminal:

pkgutil --file-info /usr/bin/sudo

After that follow the steps below:

  1. Restart the OSX with holding down keys Cmd-S
  2. Choose in the menu "Utilities" the option "Terminal"
  3. Force check the file with command: /sbin/fsck/ -fy
  4. Mount the file system with command: /sbin/mount -uw /
  5. Change the permission on sudo: chmod 4511 /usr/bin/sudo
  6. Now reboot the computer with command: reboot
1
  • How does this recreate the admin account? What is the purpose of running pkgutil --file-info /usr/bin/sudo?
    – nohillside
    Commented Mar 8, 2019 at 9:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .