← 返回命令列表

Linux command

lslogins 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

Show all users

lslogins

Show only user accounts

lslogins --user-accs

Show only system accounts

lslogins --system-accs

Show details for a specific user

lslogins [username]

List members of specific groups

lslogins --groups [group1,group2]

Show last-login information

lslogins --last

Show failed login attempts

lslogins --failed

Show supplementary group memberships

lslogins --supp-groups

Pick specific columns

lslogins -o [USER,UID,GID,HOMEDIR,SHELL]

说明

lslogins displays information about known users and groups on a Linux system, combining data from `/etc/passwd`, `/etc/shadow`, `/etc/group`, `lastlog`, `faillog`, and wtmp. It is a more comprehensive replacement for piecing together output from `who`, `last`, `id`, and `getent`. By default it prints a table with one row per user. Output columns and format can be tuned with `-o`, `--raw`, `--json`, `--colon-separate`, and `--export` for scripting.

参数

-a, --acc-expiration
Show last password change and account/password expiration dates.
-c, --colon-separate
Separate user records with a colon instead of a newline.
-e, --export
Output in `NAME="value"` shell-sourceable form.
-f, --failed
Include data about each user's last failed login.
-G, --supp-groups
Show supplementary groups.
-g, --groups _GROUPS_
Only show users that belong to one of the listed groups (comma-separated).
-L, --last
Show last-login information from `lastlog`.
-l, --logins _LOGINS_
Only show users whose login name or UID is in the comma-separated list.
-n, --newline
Print each field on its own line.
--noheadings
Suppress column headers.
--notruncate
Do not truncate long output columns.
-o, --output _LIST_
Comma-separated list of columns to display. Use `--help` for the full column list.
--output-all
Print all available columns.
-p, --pwd
Show password status information.
-r, --raw
Raw, unformatted output.
-s, --system-accs
Show only system accounts (UID below the configured threshold).
-u, --user-accs
Show only non-system user accounts.
-J, --json
Output in JSON.
-Z, --context
Show SELinux user context.
--time-format _TYPE_
`short`, `full`, or `iso` formatting for date columns.
-V, --version
Print version information.
-h, --help
Show help and the list of supported columns.

FAQ

What is the lslogins command used for?

lslogins displays information about known users and groups on a Linux system, combining data from `/etc/passwd`, `/etc/shadow`, `/etc/group`, `lastlog`, `faillog`, and wtmp. It is a more comprehensive replacement for piecing together output from `who`, `last`, `id`, and `getent`. By default it prints a table with one row per user. Output columns and format can be tuned with `-o`, `--raw`, `--json`, `--colon-separate`, and `--export` for scripting.

How do I run a basic lslogins example?

Run `lslogins` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -a, --acc-expiration do in lslogins?

Show last password change and account/password expiration dates.