Man id что это
Перейти к содержимому

Man id что это

  • автор:

Man id что это

Print user and group information for the specified USER, or (when USER omitted) for the current user.

-a ignore, for compatibility with other versions -Z, —context print only the security context of the process -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 -z, —zero delimit entries with NUL characters, not whitespace; not permitted in default format —help display this help and exit —version output version information and exit

Man id что это

Эта команда выводит информацию об указанном пользователе USERNAME или текущем пользователе, который запустил данную команду и не указал явно имя пользователя. По умолчанию выводятся подлинные числовые идентификаторы пользователя (UID) и группы (GID), действующие (именные) идентификаторы пользователей и групп, а также идентификаторы других групп, в которых состоит пользователь.

ПРИМЕР

$ id
uid=500(aleksander) gid=500(aleksander) группы=500(aleksander),19(proc),22(cdrom),71(floppy), 80(cdwriter),81(audio),83(radio)
$

Id command in Linux

Discuss ID command in linux with our step-by-step tutorial. It is used to retrieve information about the current user/specified user's identity.

Id command in Linux

Introduction

Before we discuss Id command in linux, let’s briefly understand-What is Id Command ?

The id command in Linux is used to retrieve information about the current user or specified user’s identity and group memberships. It provides details such as User ID (UID), Group ID (GID), supplementary groups, and more. The id command is helpful for checking user permissions and diagnosing access-related issues.

id is a command-line tool that displays the current and valid user and group IDs.

In this tutorial, we will talk about the id command.

Using the id Command

The id command has the following syntax:

The id command displays information about the currently logged-in user if the username is not specified.

id prints the real user ID ( uid ), the user’s real primary group ID ( gid ), and the real IDs of the supplemental groups ( groups ) the user belongs to when run without any options. Only when the effective user ID, group ID, and supplemental group IDs differ from the true ones are they printed.

id additionally prints the user’s security context ( context ) if SELinux is enabled:

Pass the username or user ID as a parameter to the id command to get information about another user:

If the system already has a user with the same name as the supplied ID, the name look-up takes precedence. To avoid the ID being misinterpreted as a name, prefix it with the + sign when using it as an argument.

If you have a user with the name 1010 and another with the ID 1010 , for example, typing id 1010 will reveal information about the user with the name 1010 . Type id +1010 to get information about the user with ID 1010 .

id Command Options

The id command has a number of arguments that allow you to display only certain data. When utilizing id in shell scripts, this is useful.

Use the -u ( —user ) option to print only the effective user ID:

With the -g ( —group ) option, id will only print the effective group ID:

To print the effective IDs of all groups to which the user belongs, use the -G ( —groups ) option:

Use the -n , —name option to output names instead of numbers. This option can only be used in conjunction with the -u , -g , and -G options.

Running the id command with the -un parameters produces the same results as running whoami , and running id -Gn produces the same results as running groups.

The -r , ( —real ) option can be combined with the -u , -g , and -G options to output real numbers rather than effective values:

Use the -Z ( —context ) option to print only the process’s security context, which is normally the user’s security context:

id sends an error message if SELinux is disabled:

The -z ( —zero ) option instructs id to use the NUL character instead of whitespace to delimit the output items:

When piping the output to a command that can parse newlines, this can be handy.

FAQs for Id Command in Linux

What is the purpose of the id command?

The id command is used to display user and group identity information, including User ID (UID), Group ID (GID), and supplementary group memberships.

How do I use the id command?

To use the id command, open a terminal and type id . It will display information about the current user or the user specified as an argument.

What information does the id command display?

The id command displays the User ID (UID), Group ID (GID), and supplementary group IDs of the current user or a specified user.

What is User ID (UID) in the id command output?

User ID (UID) in the id command output represents the unique identifier assigned to each user by the system. It is used to differentiate between different users.

What is Group ID (GID) in the id command output?

Group ID (GID) in the id command output represents the unique identifier assigned to each group by the system. It is used to associate multiple users to a specific group.

How can I determine the current user’s UID and GID using the id command?

By running the id command without any arguments, it displays the User ID (UID) and Group ID (GID) of the current logged-in user.

Where can I find more information about the id command?

You can refer to the id command’s manual page by typing man id in the terminal. Additionally, online resources and Linux documentation provide further explanations and usage examples of the id command.

Conclusion

If no user name or ID is specified as an argument, the id command publishes information about the currently logged in user.

If you have any queries, please leave a comment below and we’ll be happy to respond to them.

Команда id в Linux

id — это утилита командной строки, которая выводит реальные и действующие идентификаторы пользователей и групп.

Использование команды id

Синтаксис команды id следующий:

Если имя пользователя не указано, команда id отображает информацию о текущем вошедшем в систему пользователе.

При вызове без какой-либо опции id печатает реальный идентификатор пользователя ( uid ), реальный идентификатор основной группы пользователя ( gid ) и реальные идентификаторы дополнительных групп ( groups ), к которым принадлежит пользователь. Действующий идентификатор пользователя, идентификатор группы и идентификаторы дополнительных групп печатаются только в том случае, если они отличаются от реальных.

Если SELinux включен, то id также выводит контекст безопасности ( context ) пользователя:

Чтобы получить информацию о другом пользователе, передайте имя пользователя или идентификатор пользователя в качестве аргумента команде id :

В случае, если в системе существует пользователь с именем, совпадающим с предоставленным идентификатором, поиск имени имеет приоритет. При использовании идентификатора пользователя в качестве аргумента префикс идентификатора с помощью символа + чтобы избежать интерпретации идентификатора как имени.

Например, если у вас есть пользователь с именем 1010 и другой пользователь с идентификатором 1010 , при вводе id 1010 команда отобразит информацию о пользователе с именем 1010 . Чтобы получить информацию о пользователе с ID 1010 , введите id +1010 .

Параметры команды id

Команда id принимает несколько параметров, которые позволяют отображать только определенную информацию. Это полезно при использовании id в сценариях оболочки.

Чтобы распечатать только действующий идентификатор пользователя, используйте параметр -u ( —user ):

Параметр -g ( —group ) указывает id выводить только эффективный идентификатор группы:

Используйте параметр -G ( —groups ), чтобы распечатать эффективные идентификаторы всех групп, к которым принадлежит пользователь :

Чтобы напечатать имена вместо чисел, используйте параметр -n , —name . Этот параметр можно использовать только в сочетании с -u , -g и -G .

Выполнение команды id с параметрами -un дает тот же результат, что и запуск whoami , а результат id -Gn эквивалентен выходным данным команды groups .

Параметр -r , ( —real ) можно использовать в сочетании с -u , -g и -G для вывода реальных, а не эффективных значений:

Чтобы распечатать только контекст безопасности процесса, который обычно является контекстом безопасности пользователя, используйте параметр -Z ( —context ):

Если SELinux отключен , id выводит сообщение об ошибке:

Параметр -z ( —zero ) указывает id ограничивать выходные элементы символом NUL, а не пробелом:

Это может быть полезно при передаче вывода в команду, которая может анализировать символы новой строки.

Выводы

Команда id выводит информацию о данном пользователе или о текущем вошедшем в систему пользователе, если в качестве аргумента не указано имя пользователя или идентификатор.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *