Users of the Linux User Management (User) inquiry papers

Author: North-South-North
sponsorship:
from: League of Legends Community
Abstract: This paper introduces the user management, user queries Several tools introduced id, finger, groups and w, who, users;


Contents Index

First, the user query tool of principle;

Second, the user (the User) and user groups (Group) Query Tool;
. 1, the tool ID: query corresponding to the user group, and user UID and GID corresponding to the GID;
2, finger tools: used to query the user information, focusing on the user's home directory, login SHELL etc;
3, query the user login host of tools: w, the WHO, the users
4, groups user belongs to a user query;

Third, the postscript;

Fourth, the participation of correction paper;

Fifth, Acknowledgments;

Six related documents;


++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++
text
++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++


First, the user query tool of principle;

In the user management, user queries are a few common tools to complete, such as id, finger, groups, users ... ..., we all know that user's profile is to configure / etc / passwd, user group file is / etc / groups file, we query the user except through the query tool, we can directly view the profiles of users and user groups to achieve the purpose of the inquiry;

Principle user query tool also read about the user and user group profile, then according to certain rules and conditions of export, user and group configuration files is very important, so you need to first read off user management documents:

"Linux user (user) and user groups (group) Management Overview,"
"user (user) and user groups (group) Detailed Profile"


Second, the user (the User) and user groups (Group) Query Tool;


1, id tools: query user groups corresponding to the user's UID and GID and GID corresponding;

the above mentioned id tool is used to query user information, such as user groups the user belongs, such as UID and GID; id usage is very simple; we give example to explain;

语法格式: id  [参数]  [用户名]

As for what the parameters, check for yourself id --help or man id; id if the latter do not take any parameters and any user, the default display user name of the current operation of the user, user group belongs, UID and GID etc;

Example one: without any parameters and user name;

[beinan@localhost ~]$ id
uid=500(beinan) gid=500(beinan) groups=500(beinan)

Note: In the absence of any added parameters, query the current user's user name, UID, GID, and groups in which the primary user and the secondary user groups; in the present example, the user name is beinan, UID 500, belongs to the main user groups are beinan, GID 500;


Example Two: id followed by the user name;

if we want to query the UID and the corresponding content in the user's system GID, can be connected directly to a user name, but the username must be true, can be found in the / etc / passwd in;

[beinan@localhost ~]$ id linuxsir
uid=505(linuxsir) gid=502(linuxsir) groups=502(linuxsir),0(root),500(beinan)

Note: Query Information linuxsir user linuxsir, the UID 505, belongs to the main user groups are linuxsir, GID main user group is 502; the same linuxsir user is GID as the root user group members 0, is GID of 500 users beinan members of the group;

This example is an example in a different group of users, we are in the "Linux user (user) and user groups (group) Management Overview" mentioned in; correspondence between the user and the user group can be one to one, a for many, many to one, or many cross relations, please reference; in addition, you also need to have "user (user) and user groups (group) Detailed profile" article;


2, finger tool: used to query user information, focusing on the user's home directory, login SHELL etc;

finger tools focus on user information query; contents of the query includes a user name (also known as login name Login), home directory, user real name (name) ... ... office address, office phone; also includes a login terminal, write state, the closed space and time;

Our most popular finger to query the user's home directory, the user's real name, the type SHELL, as well as office address and telephone use, which is a parameter -l long format output; and modifying the user's home directory, real name, office address and office telephone we are generally able to live chfn command;


Syntax:


finger [parameter options] [username]
the -l using long format (the default), displayed by -s option contains all the information, as well as home directories, office address, office phone, log SHELL, message status, .plan , .project, and .forward;
-m ban users real name to match;
-p .plan the content and .project files omitted;
-s display short format, the user name (also known as login name Login), real name (nAME), which terminal login (Tty) in write status, idle time (idle), logon time (Login time), office location, office phone and so on;

As finger What are the parameters, you can get by finger --help or man finger, we have to tell the most commonly used parameters examples in this article;


Example one: do not take any parameters, the user does not specify a query name; defaults to add the -s parameter;

[beinan@localhost ~]$ finger
Login     Name            Tty      Idle  Login Time   Office     Office Phone
beinan    beinan sun    tty1     1:39  Nov  2 08:27
linuxsir  linuxsir open   tty2        2  Nov  2 10:03 linuxsir o +1-389-866-771

Equivalent command

[beinan@localhost ~]$ finger  -s

Note: no arguments, nor specify which user queries, finger will be the default for all users to log in short format -s output of the machine to the user name (also known as login name Login), real name (NAME), which terminal login (Tty), write status, idle time (idle), logon time (Login time), office location, office phone and so on;

In this example, there are beinan user logs on, the real name is beinan sun (the name is real name of the user, if not set when you add a user, not shown), registered in the terminal tty1, empty and closing time is 1 minute 39 seconds, the login time is Nov / 2/08: 27, office no name, no office phone;

Please explain this example beinan control user records, we take a look at this example linuxsir user information; should not be difficult.

About write state, if there is no output at the back Tty, said it is written, if * appears, indicating that no written or prohibited, as in the following example, ftp user does not log in through the terminal, because Tty is *, while Tty and there are a *, written or not written indicating the prohibition state (when the user is not logged in);

[beinan@localhost ~]$ finger -s ftp
Login     Name       Tty      Idle  Login Time   Office     Office Phone
ftp       FTP User    *     *  No logins

We may be in short form to query a user information output in short format, as in the following example;

[beinan@localhost ~]$ finger  -s   beinan

Example 2: Example -l respect to the output parameters of the user information length format;

finger -l case if you do not add a user name, you can list all user login information via tty; if you want to query a user, directly specify the user can specify one or more; what is tty login? If you are operating in full-screen text interface, you can press CTRL + F2 or CTRL + F3 or CTRL + F4, etc., to several different users log on to the host computer, you will see that each user has a different tty;

[beinan@localhost ~]$ finger -l
[beinan@localhost ~]$ finger -l  beinan linuxsir   注:可以同时查询几个用户信息,以长格式输出;

[beinan@localhost ~]$ finger beinan
Login: beinan                           Name: beinan sun
Directory: /home/beinan                 Shell: /bin/bash
On since Wed Nov  2 08:27 (CST) on tty1    2 hours 29 minutes idle
On since Wed Nov  2 10:50 (CST) on pts/0 from :0.0
No mail.
No Plan.

In this example, a user query is beinan, real name is beinan sun, the home directory is / home / beinan, the use SHELL type bash; then is by which terminal logged in, login time, is not a mail, there Plan Wait;

Three examples: Examples of combinations of parameters;

[beinan@localhost ~]$ finger -lp   beinan
Login: beinan                           Name: beinan sun
Directory: /home/beinan                 Shell: /bin/bash
On since Wed Nov  2 08:27 (CST) on tty1    2 hours 36 minutes idle
On since Wed Nov  2 10:50 (CST) on pts/0 from :0.0
No mail.

Note: Query beinan user information, and outputs the long format, and does not output .Plan and the content .Project;

Example IV: Comparison finger -s and who is and w;

For finger So much for it, very simple tools, when used with the -s parameter, you are the best tool for the control and w and who to see and who w finger -s and output what similarities and differences, and who are w which users login host query; and finger -s it, whether to log or not to log the user can check; but the content found in focusing on different; look at their example;

[beinan@localhost ~]$ finger -s
Login     Name            Tty      Idle  Login Time   Office     Office Phone
beinan    beinan sun      tty1     3:03  Nov  2 08:27
beinan    beinan sun      pts/0          Nov  2 10:50 (:0.0)
linuxsir  linuxsir open   tty2     1:26  Nov  2 10:03 linuxsir o +1-389-866-771

[beinan@localhost ~]$ w
11:30:36 up  3:04,  3 users,  load average: 0.30, 0.15, 0.10
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
beinan   tty1     -                08:27    3:03m  2:52   0.00s /bin/sh /usr/X11R6/bin/startx
linuxsir tty2     -                10:03    1:26m  0.01s  0.01s -bash
beinan   pts/0    :0.0             10:50    0.00s  0.16s  0.00s w

[beinan@localhost ~]$ who
beinan   tty1         Nov  2 08:27
linuxsir tty2         Nov  2 10:03
beinan   pts/0        Nov  2 10:50 (:0.0)


3, query the user login host of tools: w, who, users

w, who tool and users are logged on user queries the current host; another finger -s can also query; focus is different; please see the contrast with his own; after all, simply, introduced here only;

[beinan@localhost ~]$ w
12:09:56 up  3:43,  7 users,  load average: 0.16, 0.10, 0.04
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
beinan   tty1     -                08:27    3:42m  3:09   0.00s /bin/sh /usr/X11R6/bin/startx
linuxsir tty2     -                10:03    2:06m  0.01s  0.01s -bash
beinan   pts/0    :0.0             11:36    1:09   0.15s  0.15s bash
beinan   pts/1    :0.0             11:37    1:12   0.21s  0.21s bash
beinan   pts/2    :0.0             12:02    6:52   0.09s  0.09s bash
beinan   pts/3    :0.0             12:05   12.00s  0.11s  0.06s ssh [email protected] -p 17007
beinan   pts/4    :0.0             12:06    0.00s  0.21s  0.00s w

[beinan@localhost ~]$ who
beinan   tty1         Nov  2 08:27
linuxsir tty2         Nov  2 10:03
beinan   pts/0        Nov  2 11:36 (:0.0)
beinan   pts/1        Nov  2 11:37 (:0.0)
beinan   pts/2        Nov  2 12:02 (:0.0)
beinan   pts/3        Nov  2 12:05 (:0.0)
beinan   pts/4        Nov  2 12:06 (:0.0)

[beinan@localhost ~]$ users
beinan beinan beinan beinan beinan beinan linuxsir


4, groups the user belongs to a user query;

Groups usage is very simple, is to query which user or users group user belongs;

语法格式:  groups  用户名

Example:

[beinan@localhost ~]$ groups beinan  注:查询beinan所归属的用户组;

beinan : beinan   注:beinan 是beinan用户组下的成员;
[beinan@localhost ~]$ groups linuxsir    注:查询linuxsir用户所归属的用户组;
linuxsir : linuxsir root beinan    注:linuxsir用户是linuxsir用户组、beinan用户组、root用户组成员; 

The main groups are querying user belongs to a user group name, and id command the best contrast; so these two tools have to understand;


Third, the postscript;

this paper is very simple document, spend ten minutes will be able to see finished, but for me now to write an entry-level series of documents, and then simply have to tell beginners, is not it? Time of this writing, I have a query tool for users as "Linux user and group management tools introduced," the document read, read, but found the document is too long, so I had to query the user as a separate the first issue to articles;

My next plan is a document went on to write user management tools, such as the user to add, delete, modify, and other tools; if successful, will be completed in two days, but this is just plan; super powers because the write control when I said with a day or two but I wrote twelve days;

Fourth, to participate in correcting this article;

after this document, I want you to participate in the amendment, after all, a person write something certainly exist problem, several heads are better than one head is much better now; please bear with pointers; for example, this article about user query tool works may not be accurate or lack of expression; in addition w, the principle of online users who query did not mention, if Which brothers have time to query the online users list alone tool to written documents; thank you;


Fifth, Acknowledgments;


Sixth, the related documentation;

"Linux user (user) and user groups (group) Management Overview,"
"user (user) and user groups (group) Profile Detailed"
"Linux users (User) inquiry chapter"
"Linux User Management Tool Introduction " "
control Linux system root authority '
' in the Linux system, add bulk users operating procedures "

Reproduced in: https: //www.cnblogs.com/licheng/archive/2008/01/21/1047102.html

Guess you like

Origin blog.csdn.net/weixin_34290096/article/details/92630339