userinfo Command in Linux



User administration in Linux is the central aspect of ensuring system security and functionality. The userinfo command is a utility for retrieving detailed information about a user account so that system administrators and users can receive vital information pertaining to authentication, group membership, permissions, and login history.

Whether auditing user activity or debugging account permissions, userinfo delivers a readable and formatted output, making user administration effective.

Table of Contents

Here is a comprehensive guide to the options available with the userinfo command −

Understanding userinfo Command

The userinfo command is useful for system administrators and users to retrieve user-related information including −

  • User ID (UID) and Group ID (GID) − Identifies the system-specific user ID.
  • Home Directory − Specifies the directory where user-specific files are kept.
  • Login Shell − Determines the default command-line shell for the user.
  • Group Memberships − Indicates other groups the user belongs to. Recent Login History: Shows previous login timestamps and authentication history.

Syntax of userinfo Command

The basic syntax for the userinfo command is −

userinfo [options] username

Where −

  • [options] − Customizes the output to display specific user details.
  • username − Defines the user account for which information should be retrieved.

userinfo Command Options

Unlike all the user management commands except userinfo, userinfo does not accept its own special command-line options. It does accept standard X program options, including −

  • display − Indicates the display that the application will be running on, helpful for GUI run.
  • Other X-related choices − These choices determine window behavior, font choice, and appearance of the interface in graphical environments.

Since userinfo relies on standard X program options, users can refer to the X(1) man page for detailed descriptions of supported flags.

Examples of userinfo Command in Linux

Let's now take a look at a set of examples that demonstrate how the userinfo command retrieves essential user data.

  • Displaying Basic User Information in a GUI Session
  • Check Home Directory and Shell
  • Retrieving UID and GID with Font Customization
  • Viewing Group Memberships with Custom Window Size

Displaying Basic User Information in a GUI Session

A system administrator needs to retrieve a user's essential details but wants the output displayed on a specific graphical interface (X session) −

userinfo -display :0.0 john

The -display :0.0 option ensures output appears on the primary graphical display, useful when working with multiple monitors. The "userinfo john" retrieves key user details such as UID (User ID), GID (Group ID), home directory, and default shell.

Check Home Directory and Shell

A security administrator is monitoring login timestamps and wants the userinfo command to execute on a secondary display.

userinfo -display :1.0 -font "monospace" alice

The -display :1.0 option sends output to a second graphical interface, ensuring login details appear where needed. The -font "monospace" option improves readability, making user authentication data clearer in graphical environments.

Retrieving UID and GID with Font Customization

To check which groups a user belongs to while controlling window dimensions, use the following command −

userinfo -font "monospace" guest_user

-font "monospace" adjusts the text output font, ensuring easy readability. The command fetches numeric user and group IDs, useful for permission validation.

Viewing Group Memberships with Custom Window Size

Administrators often need to verify the groups assigned to a user while ensuring the output fits within a defined display area.

userinfo -geometry 80x24 developer_mike

The -geometry 80x24 option specifies the window dimensions, preventing content from exceeding screen space. The command retrieves all groups the user is a member of, ensuring correct access levels.

Adjusting Background Color for Readability

Users working with graphical environments may require better contrast for visibility when viewing authentication details.

userinfo -bg blue tom

Applying background modifications ensures clear and accessible information within GUI-based applications.

Conclusion

The userinfo command is a valuable utility for fetching structured user account data in Linux. Whether verifying login history, group membership, home directory configuration, or authentication information, userinfo simplifies account monitoring while coexisting well with graphical sessions through X program options. Because userinfo does not have its own command-line options, inclusion of X-related options enables appearance customization in output, contributing to user management in GUI sessions.

Knowing and utilizing the userinfo command properly helps improve visibility, keep access control under control, and make system administration easy.

Advertisements