How to View users and user groups in linux

Source: Internet
Author: User
Tags addgroup
Whois function description: find and display user information. Syntax: whois [account name] supplementary description: the whois command searches for and displays the user information of the specified account, because it searches for the WHOIS database of NetworkSolutions, therefore, the account name must be noted above...

 

Whois
Function description: search for and display user information.
Method: whois [account name]
Note: The whois command will search for and display the user information of the specified account, because it is found in the WHOIS database of Network Solutions, so the account name must be registered above for retrieval, the name is case-insensitive.
---------------------------------------------------------
Whoami

Function description: the user name is displayed first.
Syntax: whoami [-- help] [-- version]
Note: the user name is displayed. This command is equivalent to executing the "id-un" command.
Parameters:
-- Help online help.
-- Version: displays the version information.
---------------------------------------------------

Who

Function description: displays the user information currently logged on to the system.
Syntax: who [-Himqsw] [-- help] [-- version] [am I] [record files]
Note: If you execute this command, you will find that there are users logging on to the system. the terminals used to log on to the account will be listed when you execute the who command separately, the logon time and where to log in or which X monitor is being used.
Parameters:
-H or -- heading displays the title information columns of each column.
-I or-u or -- idle indicates the idle time. if the user performs any action within the previous minute, it indicates ". ", if the user has not performed any action for more than 24 hours, the" old "string is displayed.
-M this parameter has the same effect as the specified "am I" string.
-Q or -- count only displays the name and total number of accounts logged on to the system.
-S this parameter will be ignored and will not be processed. it is only responsible for solving compatibility issues with other versions of the who command.
-W or-T or -- mesg or -- message or -- writable displays the user information status bar.
-- Help online help.
-- Version: displays the version information.

----------------------------------------------------
W

Function description: displays the user information currently logged on to the system.
Syntax: w [-fhlsuV] [user name]
Note: If you execute this command, you can find out who are currently logged on to the system and the programs they are executing. Run w
The command displays all users. you can also specify a user name to display only information about a user.
Parameters:
-F. enable or disable the function to show where the user logs on to the system.
-H: the title information column of each column is not displayed.
-L use the detailed format list, which is the default value.
-S uses a concise format list, which does not display the user logon time, CPU time consumed by terminal jobs and programs.
-U ignores the name of the execution program and the CPU time consumed by the program.
-V displays the version information.
-----------------------------------------------------

Finger command

The finger command is used to query user information. it usually displays the user name, main directory, stagnation time, logon time, logon shell, and other information of a user in the system. To query user information on a remote machine, you need to connect the user name to "@ host name" in the format of [user name @ host name]. However, the network host to be queried must run the finger daemon.
The common format of this command is:
Finger [option] [user] [user @ host]
The meanings of the options in the command are as follows:
-S displays the user's registration name, actual name, terminal name, write status, stagnation time, logon time, and other information.
-L in addition to the information displayed with the-s option, it also displays information such as the user's home directory, logon shell, email status, and under the user's home directory. plan ,. project and. the content of the forward file.
-P is the same as the-l option except that the. plan and. project files are not displayed.
[Example] run the finger command on the local machine.
$ Finger xxq
Login: xxq Name:
Directory:/home/xxq Shell:/bin/bash
Last login Thu Jan 1 21:43 (CST) on tty1
No mail.
No Plan.
$ Finger
Login Name Tty Idle Login Time Office Phone
Root * 1 28 Nov 25
......

------------------------------------------------------------------

The/etc/group file contains all groups.
All usernames in the/etc/shadow and/etc/passwd systems


Method for modifying the group to which the current user belongs

Usermod or you can directly modify the/etc/paaawd file.

----------------------------------------------------------------

Vlock (virtual console lock)
Function description: lock a virtual terminal.
Syntax: vlock [-achv]
Note: executing the vlock command can lock the virtual terminal to prevent other users from using it.
Parameters:
-A or -- all locks a terminal-phase job. if you use this parameter on a full-screen terminal, the keyboard is used.
The function of switching the terminal is disabled.
-C or -- current locks the current terminal-phase job, which is the default value.
-H or -- help online help.
-V or -- version displays version information.
--------------------------------------------------------
Usermod

Function description: modify a user account.
Syntax: usermod [-LU] [-c <备注> ] [-D <登入目录> ] [-E <有效期限> ] [-F <缓冲天数> ] [-G <群组> ] [-G <群组> ] [-L <帐号名称> ] [-S] [-u] [user account]
Note: usermod can be used to modify user account settings.
Parameters:
-C <备注> Modify the remarks of a user account.
-D logon Directory> modify the directory when a user logs in.
-E <有效期限> Modifies the validity period of an account.
-F <缓冲天数> The account is closed after the password expires.
-G <群组> Modify the group to which the user belongs.
-G <群组> Modify the additional group to which the user belongs.
-L <帐号名称> Modify the account name.
-L lock the user password to make it invalid.
-S: modify the shell used after user login.
-U: modify the user ID.
-U unlocks the password.
-------------------------------------------------------
Userdel
Function description: delete a user account.
Syntax: userdel [-r] [user account]
Note: userdel can delete user accounts and related files. If no parameter is added, only the user account is deleted, and related files are not deleted.
Parameters:
-F delete the user's logon directory and all files in the directory.
----------------------------------------------------------

Userconf

Function description: sets a program for a user account.
Syntax: userconf [-- addgroup <群组> ] [-- Adduser <用户id> <群组> <用户名称> ] [-- Delgroup <群组> ] [-- Deluser <用户id> ] [-- Help]
Note: userconf is actually a symbolic connection to linuxconf and provides graphical interface operations for administrators to establish and manage various accounts. If no parameters are added, the graphic interface is displayed.
Parameters:
-- Addgroup <群组> Add a group.
-- Adduser <用户id> <群组> <用户名称> Add a user account.
-- Delgroup <群组> Delete a group.
-- Deluser <用户id> Delete a user account.
-- Help: displays help.

------------------------------------------------------

Useradd

Function description: Create a user account.
Syntax: useradd [-mMnr] [-c <备注> ] [-D <登入目录> ] [-E <有效期限> ] [-F <缓冲天数> ] [-G <群组> ] [-G <群组> ] [-S] [-u] [user account] or useradd-D [-B] [-e <有效期限> ] [-F <缓冲天数> ] [-G <群组> ] [-G <群组> ] [-S]

Note: useradd can be used to create a user account. After the account is created, use passwd to set the password of the account, and use userdel to delete the account. The account created using the useradd command is actually saved in the/etc/passwd text file.

Parameters:
-C <备注> Add remarks. The remarks are saved in the remarks field of passwd.
-D <登入目录> Specify the start directory when the user logs in.
-D. change the default value.
-E <有效期限> The validity period of the specified account.
-F <缓冲天数> The number of days after the password expires.
-G <群组> The group to which the user belongs.
-G <群组> Specify the additional group to which the user belongs.
-M automatically creates the user's logon directory.
-M: do not automatically create a user's logon directory.
-N cancel creating a group named by the user name.
-R: create a system account.
-S specifies the shell used after the user logs on.
-U: User ID

========================================================== ====================================

InLinuxMedium,What commands can be used to view the user groups that contain users??

A user Group is a collection of users with some common features ). The user Group configuration files include/etc/group and/etc/gshadow./etc/gshadow is the encrypted information file of/etc/group. under this title, what is GID;

1. Explanation of/etc/group;

The/etc/group file is the configuration file of the user group. it contains the user and user group, and shows which user group or user group the user belongs, because a user can belong to one or more different user groups, users of the same user group have similar features. For example, if we add a user to the root user group, this user can browse the files in the root user's home directory. if the root user opens the read and write permissions for a file, all users of the root user group can modify this file. if it is an executable file (such as a script), users of the root user group can also execute it;
User group features provide great convenience for system administrators in system management, but security is also worth noting. for example, a user has the most important content for system management, it is best to allow users to have independent user groups, or set the permissions of files under the user to be completely private. In addition, the root user group should not easily add normal users,

2. detailed analysis of/etc/group content

The content of/etc/group includes the User Group, User group password, GID, and User included in the User Group. each User group has a record. the format is as follows:

Group_name: passwd: GID: user_list

Each record in/etc/group has four fields:
Field 1: User group name;
Field 2: User Group password;
Third Field: GID

Field 4: user list. each user is separated by a comma. This field can be blank. if the field is empty, it indicates that the user group is the user name of GID;
For example:

Root: x: 0: root, linuxsir note: User Group root, x is the password segment, indicating no password is set, GID is 0, root User groups include root, linuxsir, and other users whose GID is 0 (which can be viewed through/etc/passwd); beinan: x: 500: linuxsir note: User Group beinan, x indicates the password segment, indicating that no password is set. GID is 500. the beinan user group includes the linuxsir user and the user whose GID is 500 (which can be viewed through/etc/passwd). linuxsir: x: 502: linuxsir note: User Group linuxsir, x is the password segment, indicating that no password is set, GID is 502, users with linuxsir and GID 502 under the linuxsir User Group (you can view them through/etc/passwd); helloer: x: 503: Note: User Group helloer, x is the password segment, indicates that no password is set, GID is 503, and the helloer user group contains users whose GID is 503, which can be viewed through/etc/passwd;


The related records corresponding to/etc/passwd are:

Root: x: 0: 0: root:/bin/basw.inan: x: 500: 500: beinan sun:/home/beinan:/bin/bashlinuxsir: x: 505: 502: linuxsir open, linuxsir office, 13898667715:/home/linuxsir:/bin/bashhelloer: x: 502: 503:/home/helloer:/bin/bash

We can see that the helloer user group includes helloer users. Therefore, we can view the users owned by a user group by comparing/etc/passwd and/etc/group.

========================================================== ======================================

In LINUX, what commands can be used to view all current users and user groups?

Is there such a command for listing all the existing systems? What does the command above chmod o-rw config. inc. php mean? ------------------------------------ Use the file browsing command to view the user file in/etc/passwd, for example, less/etc/passwd or cat/etc/passwd chmod. the o command is used to change the permissions of the owner. -rw is to remove the read and write permissions. if you want to add the read and write permissions, + rw will be used for the subsequent config. inc. php is the file name, that is, the file you want to change permissions! Of course, you can also use man chmod to view more methods of this command.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.