I. Account information display
1.groups command
Use the groups command to display the group memberships for a specified user account.
[email protected] ~]# groups--help
usage:groups [OPTION] ... [USERNAME] ...
Print group memberships for each USERNAME or, if no USERNAME are specified, for
The current process (which, differ if the groups database has changed).
--help Display this Help and exit
--version output version information and exit
Report groups bugs to [email protected]
GNU coreutils Home page:
General help using GNU software:
For complete documentation, Run:info coreutils ' groups invocation
Example: See which group the user Zhang is a member of.
[email protected] ~]# groups Zhang
Zhang:zhang Zhangsan
[Email protected] ~]#
You can see that user Zhang is a user belonging to the Zhang Group and the Zhangsan group.
2.id command
Use the ID command to display the ID of the user and the GID of the group to which the user belongs.
[[email protected] ~]# ID--help
Usage:id [OPTION] ... [USERNAME]
Print User and group information for the specified USERNAME,
or (when USERNAME omitted) is the current user.
-a ignore, for compatibility and other versions
-Z,--context print only the security context of the current user
-G,--group print only the effective group ID
-G,--groups print all group IDs
-N,--name print a name instead of a number, For-ugg
-R,--real print the real ID instead of the effective ID, With-ugg
-U,--user print only the effective user ID
--help Display this Help and exit
--version output version information and exit
Without any OPTION, print some useful set of identified information.
Report ID bugs to [email protected]
GNU coreutils Home page:
General help using GNU software:
For complete documentation, RUN:INFO coreutils ' ID invocation '
[Email protected] ~]#
Example 1: Query user Zhang's UID, GID, and attribution group.
[[email protected] ~]# ID Zhang
uid=513 (Zhang) gid=513 (Zhang) groups=513 (Zhang), 501 (Zhangsan)
[Email protected] ~]#
User Zhang's UID is 513, the default group is Zhang, the default user group GID is 513, belonging to the Zhang and Zhangsan group.
Example 2: Displays the GID of the primary group that the user Zhang belongs to.
[Email protected] ~]# id-g Zhang
513
[Email protected] ~]#
Example 3: Displays the GID of the group that the user Zhang belongs to.
[Email protected] ~]# id-g Zhang
513 501
[Email protected] ~]#
You can see that the GID of the group that the user Zhang belongs to is 513 and 501.
Example 4: Displays the UID of the user Zhang.
[Email protected] ~]# id-u Zhang
513
[Email protected] ~]#
You can see that the UID of user Zhang is 513.
3.W command
Use the W command to query the user who is logged on to the current computer in detail.
Example 1: Displays the user details of the logged on current computer.
4.who command
Use the WHO command to display simple information about the user who is logged on to the current computer.
[email protected] ~]# who
Root pts/0 2015-01-14 04:35 (192.168.12.1)
[Email protected] ~]#
5.chage
In the Linux system, you can use the Chage command to manage the aging of the user's password, preventing the user password from being compromised for prolonged use, or being hacked by a hacker's password.
[Email protected] ~]# chage
usage:chage [Options] [LOGIN]
Options:
-D,--lastday Last_day set Date of last password change to Last_day
-E,--expiredate expire_date set account expiration DATE to Expire_date
-H,--help display this help message and exit
-I,--inactive inactive set password inactive after expiration to inactive
-L,--list Show account aging Information
-M,--mindays min_days set minimum number of days before password change to Min_days
-M,--maxdays Max_days set Maximim number of days before password change to Max_days
-W,--warndays warn_days set expiration warning days to Warn_days
[Email protected] ~]#
Example: Displays the user's current password invalid information.
[Email protected] ~]# chage-l Zhang
Last password Change:jan 13, 2015
Password Expires:never
Password Inactive:never
Account Expires:never
Minimum number of days between password change:0
Maximum number of days between password change:99999
Number of days of warning before password expires:7
[Email protected] ~]#
Display and secure account information for Linux account