View User
A), view the currently logged-on user
The code is as follows:
[Root@krlcgcms01 ~]# W
Function Description: Displays the user information of the current login system.
Syntax: w [-fhlsuv][user name]
Supplementary note: The implementation of this directive will tell the users who are currently logged into the system and the procedures they are implementing. Separate execution W
Directive displays all users, you can also specify a user name and display only information about a user.
Parameters:
-F turns on or off to show where the user is logged into the system.
-H does not display header information columns for each field.
-L uses the detailed format list, which is a preset value.
-S uses a concise format list, which does not display the user login time, the terminal stage job and the CPU time consumed by the program.
-U ignores the name of the executing program and the information that the program consumes CPU time.
-V Displays version information.
The code is as follows:
[Root@krlcgcms01 ~]# who
Function Description: Displays the user information of the current login system.
Grammar: Who [-himqsw][--help][--version][am i][record file]
Supplementary note: Implementation of this directive can be informed of the current user login system, the individual implementation of the WHO directive will be listed login account, the use of terminals, login time and from where to log in or use which x monitor.
Parameters:
-h or--heading display header information columns for each field.
-I or-u or--idle display idle time, if the user in the first minute of any action, will be marked as "." Number, if the user has no action for more than 24 hours, then the "old" string is marked.
-M The effect of this parameter is the same as the specified ' Am I ' string.
-Q or--count only displays the account name and total number of the login system.
-S This parameter ignores no processing and is responsible only for resolving compatibility issues with other versions of the WHO directive.
-W or-t or--MESG or--message or--writable displays the user's information status bar.
--help online Help.
--version Displays version information.
b), view your own user name
The code is as follows:
[Root@krlcgcms01 ~]# WhoAmI
Function Description: First appears the user name.
Syntax: WhoAmI [--help][--version]
Supplemental Note: Displays the user name of oneself, this instruction is equivalent to execute "id-un" instruction.
Parameters:
--help online Help.
--version Displays version information.
c), viewing individual user information
The code is as follows:
[Root@krlcgcms01 ~]# Finger Apacheuser
The function of the finger command is to query the user's information, usually displaying the user name, home directory, stasis time, logon time, login shell, etc. of a user in the system. If you want to query for user information on a remote computer, you need to follow the user name with "@ hostname", in the format of [username @ host name], but the network host you are querying needs to run the finger daemon.
The general format for this command is:
finger [options] [consumer] [user @ host]
The options in the command have the following meanings:
-S Displays the user's registration name, actual name, terminal name, write status, stagnation time, logon time, and other information.
-L displays information such as the user's home directory, login shell, message status, and the contents of the. Plan,. Project, and. Forward files in the user's home directory, in addition to the information displayed with the-s option.
-P is the same as the-l option except that the. plan file and the. project file are not displayed.
[Example] use the finger command on the local machine.
The code is as follows:
$ finger XXQ
LOGIN:XXQ Name:
Directory:/home/xxq Shell:/bin/bash
Last login Thu 1 21:43 (CST) on tty1
No Mail.
No plan.
$ finger
Login Name Tty Idle Login Time Office Phone
Root root *1 Nov 25 09:17
......
[Root@krlcgcms01 ~]# ID Apacheuser
d), viewing user logon Records
The code is as follows:
[Root@krlcgcms01 ~]# Last view login successful user record
[Root@krlcgcms01 ~]# lastb View logon unsuccessful user record
e), view all users
The code is as follows:
[Root@krlcgcms01 ~]# cut-d:-F 1/ETC/PASSWD
[root@krlcgcms01 ~]# cat/etc/passwd |awk-f \: ' {print $} '
User Password Management
One important aspect of user management is the management of user passwords. User account has just been created without a password, is locked by the system, can not be used, must be assigned a password to use, even if it is a blank password.
The shell command that specifies and modifies a user's password is passwd. The ultimate user can specify passwords for themselves and other users, and ordinary users can only modify their own passwords. The format of the command is:
Code:
passwd option User Name
Options you can use:
-L locks the password, that is, the account is disabled.
-u password unlock.
-D makes the account password-free.
-F forces the user to modify the password at the next logon.
If the default user name, the password for the current user is modified.
For example, if the current user is a SAM, the following command modifies the user's own password:
The code is as follows:
$ passwd
Old password:******
New password:*******
Re-enter New password:*******
If you are the ultimate user, you can specify any user's password in the following form:
The code is as follows:
# passwd Sam
New password:*******
Re-enter New password:*******
Ordinary users modify their own password, passwd command will ask the original password, verify that the user input two times after the new password, if the password entered two times, the password assigned to the user, and the ultimate user to specify the password, you do not need to know the original password. For security reasons, users should choose a more complex password, the best use of not less than 8-bit password, the password contains uppercase, lowercase letters and numbers, and should be different from the name, birthday and so on.
When you specify a blank password for the user, the following form of command is performed:
Code:
The code is as follows:
# passwd-d Sam
This command deletes the password for the user Sam so that the system will no longer ask for the password the next time the user Sam logs on.
The passwd command can also lock a user with the-l (lock) option so that it cannot log on, for example:
Code:
The code is as follows:
# passwd-l Sam