logins Command
Note: Logins command displays system login information
details only for the local users or groups which are defined in the /etc/passwd and /etc/group files.
Purpose
Displays user and system login information.
Syntax
logins [ -a ] [ -m ] [ -o ] [ -p ] [ -s ] [ -t ] [ -u ] [ -x ] [ -g Groups ] [ -l Logins ]
Description
The logins command displays
information about user and system logins. By default, the logins command
prints the following items:
- User ID
- Primary group name
- Primary group ID
- The /etc/passwd account field on user information.
The output is sorted by user ID, displaying system logins followed by user logins.
Depending on the options chosen,
the following fields can also be displayed:
- user or system login
- user ID number
- multiple group names
- multiple group IDs
- home directory
- login shell
- four password aging parameters
- /etc/passwd account field value (user name or other information)
- primary group name
- primary group ID
Flags
Item | Description |
---|---|
-a | In addition to the default output, the -a flag adds two password expiration fields to the display. These fields show how many days a password can remain unused before it automatically becomes inactive and the date that the password will expire. |
-g Groups | Displays all users belonging to group, sorted by user ID. Multiple groups can be specified as a comma separated list. Groups must specify valid group names on the system. Comma separate names when specifying more than one group. |
-l Logins | Displays the requested login. Multiple logins can be specified as a comma-separated list. Logins must specify valid user names on the system. |
-m | Displays multiple group membership information. |
-o | Formats output into one line of colon separated fields. |
-p | Displays users without passwords. |
-s | Displays all system logins. |
-t | Sorts output by user name instead of by user ID. |
-u | Displays all user logins. |
-x | Prints an extended set of information about
each selected user. Information for each user is printed on a separate
line containing the home directory, login shell, and password aging
information. The extended information includes the following:
PS for
logins with password, NP for no password or LK for
locked. |
Exit Status
- 0
- The command completed successfully.
- >0
- An error occurred.
Examples
- To list all the logins with no passwords, enter:
The output looks similar to the following:logins -p
The -p option ensures that only logins with no passwords are listed.pwdless 204 staff 1 nopwd 208 staff 1
- To list all the system logins sorted by alphabetical order enter:
The output looks similar to the following:logins -st
The -t option prints out the logins sorted alphabetically and not by uid.adm 4 adm 4 bin 2 bin 2 daemon 1 staff 1 lp 11 lp 11 lpd 9 nobody -2 root 0 system 0 sys 3 sys 3 uucp 5 uucp 5
- To list the login details of users "root' and "admin", enter:
The output looks similar to the following:logins -l root,adm
root 0 system 0 adm 4 adm 4
- To list the password aging details of users "root" and "admin"
enter:
The output looks similar to the following:logins -xl root,adm
The -x option ensures that extended password information for these logins are retrieved and printed in the output.root 0 system 0 / /usr/bin/ksh PS 021102 0 0 0 adm 4 adm 4 /var/adm /sbin/sh PS 000000 0 0 0
- To display the multiple group information of a particular user
in a colon separated format enter:
The output looks similar to the following:logins -mol root,adm
The -m option is used here to retrieve the multiple group information of a particular login (user). The -o option ensures that the output is displayed in colon separated format.root:0:system:0::bin:2:sys:3:security:7:cron:8:audit:10:lp:11 adm:4:adm:4:
- To display the users of the "staff" and "sys" groups in a colon
separated format, sorted by user name, enter:
The output looks similar to the following:logins -tsog staff,sys
bin:2:bin:2: daemon:1:staff:1: invscout:200:staff:1: root:0:system:0: sys:3:sys:3:
Files
Item | Description |
---|---|
/usr/bin/logins | Contains the logins command. |
/etc/passwd | Contains the password file. |
/etc/group | Contains the group file. |