id - macOS


The id command in macOS is used to display the user identity and group information for a user. This command is helpful for system administrators and users to verify the user and group IDs, as well as memberships in different groups. It can be effectively used to ensure correct permissions and ownerships, troubleshoot access issues, and confirm the security context in which processes will execute.


id [options] [user]
  • [options]: Optional flags that modify the command’s behavior.
  • [user]: Optional username to query the identity of. If no user is mentioned, it defaults to the current user.


  • -p or --pretty: Display the information in a human-readable format. This is often used to easily interpret the data.
  • -u, --user: Display the user ID of the specified user. If no user is specified, it shows the user ID of the current user.
  • -g, --group: Display the effective group ID of the specified user. If no user is specified, the effective group ID of the current user is shown.
  • -G, --groups: Display all group IDs of which the specified user is a member. If no user is specified, it shows the groups of the current user.

Default behavior without any option is to display user ID, group ID, and groups for the specified or current user.


  1. Basic Usage: Display the identity of the current user.
  2. Specific User: Display identity information for user username.
    id username
  3. Display User ID Only:
    id -u
  4. Display Effective Group ID Only:
    id -g
  5. Display All Group IDs: List all groups the current user belongs to.
    id -G
  6. Human-readable Format: Display a user-friendly format.
    id -p

Common Issues

  • Username Not Found: If the command throws an error saying “no such user”, verify that the username is spelled correctly.
  • Permission Denied: Some options might require elevated permissions. Run the command with sudo if needed.
  • Misinterpretation of Output: Users may confuse user ID and group ID. Note that -u is for user ID and -g is for group ID.


id can be combined with shell scripts or other commands to manage users or automate tasks involving user permissions:

USER_ID=$(id -u)
echo "Your User ID is: $USER_ID"

This script captures the user ID of the user executing the script and displays it, which could be part of a larger script for configuration or maintenance tasks.

  • whoami: Displays the username of the current user which is simpler but less detailed than id.
  • groups: Lists all the groups the current user is a member of.
  • sudo: Executes a command with elevated privileges, which can be used to view ID information for other users.

For further details, please consult the official MacOS documentation and manual pages (man id) for a deeper dive into what the id command can do and detailed descriptions of its options.