Gain Administrator Access on MAC using Commands
https://letsknowaboutcomputer.blogspot.com/2012/12/gain-administrator-access-on-mac-using.html
First, you must start the computer in Single-User Mode, a command-line mode which automatically logs in as the administrator. This function is intended facilitate computer repair. To enter this mode, hold Command [the Apple button] and S keys while booting the computer until a black screen appears. Once you reach a command line, follow the procedure to complete the boot process, enable the root account, and reboot. You only need to remember the last two commands as the system will remind you of the first three from Single-User Mode.
First, check the disk for errors by entering this command:
/sbin/fsck -fy
This is usually a quick process; it will fix any errors it finds. It is not recommended that you skip this step. After it finishes, activate write access to the hard disk by entering:
/sbin/mount -uw /
Now, initiate the main boot process with this command:
sh /etc/rc
This command will start most of the system while remaining in command-line mode. It will generate much text. If it stalls for more than one minute, you may press Control-C to abort it; you should still be able to complete the procedure. After it completes, you will be able to enable the root account by setting its password. Enter:
passwd root
It will prompt you twice for the new password for root. The cursor will not move as you enter the passwords. Now, reboot the computer by entering:
reboot
Now you can login as System Administrator. If your Mac uses the user list at the login screen, chooseOther... At the prompt, use root as the username. The password is the one you just set. Login may appear to stall briefly on the first try, but it will succeed after a few seconds wait. Once you're logged in, you will be able to access and modify any file on the computer or any setting in System Preferences. There, you can create, modify, and change the passwords of other accounts on the computer.
First, check the disk for errors by entering this command:
/sbin/fsck -fy
This is usually a quick process; it will fix any errors it finds. It is not recommended that you skip this step. After it finishes, activate write access to the hard disk by entering:
/sbin/mount -uw /
Now, initiate the main boot process with this command:
sh /etc/rc
This command will start most of the system while remaining in command-line mode. It will generate much text. If it stalls for more than one minute, you may press Control-C to abort it; you should still be able to complete the procedure. After it completes, you will be able to enable the root account by setting its password. Enter:
passwd root
It will prompt you twice for the new password for root. The cursor will not move as you enter the passwords. Now, reboot the computer by entering:
reboot
Now you can login as System Administrator. If your Mac uses the user list at the login screen, chooseOther... At the prompt, use root as the username. The password is the one you just set. Login may appear to stall briefly on the first try, but it will succeed after a few seconds wait. Once you're logged in, you will be able to access and modify any file on the computer or any setting in System Preferences. There, you can create, modify, and change the passwords of other accounts on the computer.