MacOS is Unix compliant, therefore you’ll need admin username to create, execute and access certain processes. Unlike other operating systems, just like Linux, macOS features Users and Groups. Any user added in the admin group can have administrator privileges.
Find admin username using terminal
Getting, logged-in, admin username using terminal is as simple as the following command:
- Open terminal using spotlight (Command + Space and type terminal).
- Type whoami and hit enter. It’ll show your admin-username as an output.
Enlisting all user accounts is possible using the Directory Service Command Line utility:
- Open terminal and use the command dscl . list /Users | grep -v “^_” and hit enter. Copy the username for which you want to find whether it belongs to admin group or not.
- Use command id -Gn USERNAME (replace it with username which you copied from earlier step) and hit enter.
- Find admin in the returned results, if there is admin group in the output then it means that the specific USERNAME is an administrator account.
You can use same id command for other copied usernames from the Directory Service Command Line utility.
Find admin username without terminal
A simple method to enlist usernames of an admin group inside macOS is as follows:
- Open System Preferences and find Users & Groups.
- Click the lock icon and type your password.
- You’ll see details of all the users added to different groups with specific privileges. Right click a specific Name to find its username and click Advanced Options.
- In the Home Directory path, /users/USERNAME you’ll find the username of the account which you are viewing.
You’ll notice that by opening advance options of a user, you can also change the name. However, keep in mind that changing password will not change the password of the already associated keychain (a program which stores login passwords inside macOS).
You can not only enlist all user accounts belonging to a macbook on terminal but can also find accounts with admin privileges. Finding username of a logged in user is pretty simple as using whoami command. To enlist other users, you need to execute directory service command line utility. Additionally, you can also use System Preferences for the same task.