Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Linux id command to print information about users and groups

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to use the Linux id command to print the information of the user and the group". The content of the explanation in the article is simple and clear, and it is easy to learn and understand. please follow the editor's train of thought to study and learn "how to print the information of the user and the group with the Linux id command".

Id prints real and valid information about users and groups

Summary id [OPTION]... [USER]... When there is no option for the main use, print the specified user ID information.

Option-a compatibility option, has no practical effect. -Z,-- context prints only the security context of the process. -g,-- group prints only valid group ID. -G,-- groups prints all group ID. -u,-- user prints only valid user ID. -z,-- zero separates entries with empty characters instead of default spaces. -- help displays help information and exits. -- version displays version information and exits. The following options are available only when using one or more of the-u-g-G options:

-n,-- name prints names instead of numbers. -r,-- real prints a real ID instead of a valid ID. Parameter user (optional): can be one or more, default to the current user.

A return value of 0 indicates success, while a non-zero value indicates failure.

Examples [root@localhost ~] # id uid=0 (root) gid=0 (root) groups=0 (root), 1 (bin), 2 (daemon), 3 (sys), 4 (adm), 6 (disk), 10 (wheel) explain that the UID number of user root = 0GID = 0. User root is a member of the following group:

The GID number of root group is: 0

The GID number of bin group is: 1

The GID number of daemon group is: 2

The GID number of sys group is: 3

The GID number of adm group is: 4

The GID number of disk group is: 6

The GID number of wheel group is: 10

Print the user name, UID, and all groups to which the user belongs. To do this, we can use the-an option:

[root@localhost] # id-a uid=0 (root) gid=0 (root) groups=0 (root), 1 (bin), 2 (daemon), 3 (sys), 4 (adm), 6 (disk), 10 (wheel) output all different groups ID, valid, real and complementary, we can use the-G option:

[root@localhost ~] # id-G 0 1 2 3 4 6 10 results will only show the GID number. You can compare with the / etc/group file. Here is an example of the / etc/group file:

Output only valid group ID, and output only valid group ID by using the-g option:

[root@localhost ~] # id-g 0 outputs specific user information, and we can output UID and GID related to specific user information. You only need to follow the user name after the id command:

[root@localhost ~] # id www uid=500 (www) gid=500 (www) groups=500 (www) Note that this command displays the real and valid user ID (UID) and group ID (GID). A UID is a single identity for a user. Group ID (GID) corresponds to multiple UID; and some programs may need UID/GID to run. Id makes it easier for us to find the user's UID and GID without having to search in the / etc/group file.

This command is a command in the GNU coreutils package. For help, please see man-s 1 id,info coreutils'id invocation'.

Thank you for your reading, the above is the content of "how to use the Linux id command to print the information of the user and the group". After the study of this article, I believe you have a deeper understanding of how to use the Linux id command to print the information of the user and the group, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report