Boot into Restore mode,CMD+r keys...
Look at top of screen for Utilities menu, there choose Terminal...
Missing Mac Admin Account? Create a New Admin Account in macOS
This process will involve booting into Recovery Mode to remove a setup file from the Mac, which allows the macOS setup assistant to run again, thereby allowing you to create a new admin account on the Mac. This works with macOS Monterey and Big Sur, and earlier, for both M1 and Intel Macs.
- Boot the Mac into Recovery Mode by restarting the Mac and holding down Command+R (Intel Macs) or the Power button (M1 Macs)
- For M1 Macs, choose “Options” at the boot menu that appears
- At the macOS Utilities screen, open Disk Utility
- Select “Macintosh HD – Data” from the side bar and choose to “Mount” the Data drive
- Exit out of Disk Utility
- Pull down the ‘Utilities’ menu and choose “Terminal”
- Enter the following command into the Terminal:
- cd /Volumes/Macintosh\ HD/var/db/
- Next enter the following command exactly as shown:
- rm .AppleSetupDone
- Restart the Mac and go through the Setup Assistant procedure as if the Mac was new to create a new admin user account on the Mac, this will be an administrator account
You’ll now have created a new admin account which is fresh and completely different user account than your standard user account. The standard user account and all user data still exists, assuming this was done properly.
You can either use this admin user account to authenticate as needed with administrator requests and logins, or you can modify the original user account to become an admin account again. We’ll cover that next.
How to Set Standard User Account to be Admin Account in macOS
Want to restore your original Mac user account to be an admin account again? That’s easy:
- Boot into the newly created admin account, then pull down the Apple menu and choose “System Preferences”
- Go to “Users & Groups” and click the padlock icon to be able to modify user accounts
- Select the original user account that you want to modify to Admin account privileges
- Check the box for “Allow user to administer this computer”
https://osxdaily.com/2022/03/25/no-admin-account-mac-fix-macos/#:~:text=Missing%20Mac%20Admin%20Account%3F,admin%20account%20on%20the%20Mac.
Paste these lines into Text Edit so you can arrow thru & see the spaces...
cd /Volumes/Macintosh\ HD/var/db/
rm .AppleSetupDone