id 명령어 (AIX 5.3·6.1)
https://archive.horanglab.com/posts/aix-cmd-id
핵심 정리
- 사용자의 시스템 ID(사용자 이름과 UID, 기본 그룹과 GID, 보조 그룹)를 보여 줍니다. 사용자를 주지 않으면 자신의 것입니다.
- 실효 ID가 실제 ID와 다르면 euid·egid도 보여 줍니다(예:
su뒤). -u(UID만),-g(GID만),-G(모든 그룹 ID),-n(숫자 대신 이름),-r(실효 대신 실제 ID).-l은 로그인할 때의 ID(login UID)를 보여 줍니다.su로 바꿔도 로그인 UID는 그대로입니다. AIX에만 있는 옵션입니다.- 사용자가 없거나 사용자·그룹 정보를 읽을 수 없으면 실패합니다.
- AIX 5.3과 6.1 문서의 내용이 같습니다.
| 항목 | 내용 |
|---|---|
| 버전 | AIX 5.3, AIX 6.1 (두 버전 내용 같음) |
| 원문 | IBM Commands Reference — 5.3 Volume 3, 6.1 Volume 3 |
| 파일 | /usr/bin/id |
| 관련 명령어 | whoami, groups, su, login |
목적
지정한 사용자의 시스템 ID를 보여 줍니다.
영어 원문
Displays the system identifications of a specified user.
구문
id [ User ]
id -G [ -n ] [ User ]
id -g [ -n -l | [ -n -r ] ] [ User ]
id -u [ -n -l | [ -n -r ] ] [ User ]
설명
id 명령은 지정한 사용자의 시스템 ID가 담긴 메시지를 표준 출력에 씁니다. 시스템 ID는 시스템에서 사용자와 사용자 그룹을 가리키는 숫자입니다. 해당하는 경우 다음을 씁니다.
- 사용자 이름과 실제 사용자 ID
- 사용자의 그룹 이름과 실제 그룹 ID
- 보조 그룹의 이름과 ID. 여러 그룹을 지원하는 시스템이고 사용자가 보조 그룹에 속할 때만 씁니다.
실효 사용자 ID와 그룹 ID도 쓰지만, id를 부른 사용자에 대해서만 씁니다(User 매개변수를 주면 실효 ID는 실제 ID와 같다고 봅니다). 부른 사용자의 실효 ID와 실제 ID가 다르면 다음도 씁니다.
- 실효 사용자 이름과 실효 사용자 ID
- 실효 사용자의 그룹 이름과 실효 그룹 ID
-l 옵션을 주면 로그인 UID를 보여 줍니다. 로그인 ID는 세션에 로그인할 때의 시스템 자격 증명이며, 로그인 UID는 실제로 로그인한 사용자의 사용자 ID(숫자)입니다. 로그인한 뒤 자격 증명이 바뀌지 않았으면 로그인 UID는 UID와 같습니다. 예를 들어 su 명령을 실행하면 UID는 바뀌지만 로그인 UID는 그대로입니다.
지정한 사용자가 없거나 사용자·그룹 정보를 읽을 수 없으면 id는 실패합니다.
영어 원문
The id command writes to standard output a message containing the system identifications (ID) for a specified user. The system IDs are numbers which identify users and user groups to the system. The id command writes the following information, when applicable:
User name and real user ID
Name of the user's group and real group ID
Name of user's supplementary groups and supplementary group IDs Supplementary group information is written only for systems supporting multiple-user groups and only if the specified user belongs to a supplementary group.
The id command also writes effective user and group IDs, but only for the user that invoked the id command. (If the User parameter is specified with the id command, the effective IDs are assumed to be identical to real IDs.) If the effective and real IDs for the invoking user are different, the id command writes the following effective ID information, when applicable:
Effective user name and effective user ID
Name of effective user's group and effective group ID
The id command, when specified with the -l option, displays login UID. Login ID indicates the system credentials at the time of logging in to the session. Login UID indicates the user ID (numeric value) of the user, who actually logged in. The login UID is equal to the UID for a user who has logged in to the system and whose credentials remain unchanged. For example, when the user runs the su command, the UID for the user changes and the login UID remains the same.
The id command will fail if the specified user does not exist or if the command cannot read the user or group information.
플래그
다음 플래그로 메시지의 내용과 형식을 바꿉니다.
| 플래그 | 설명 |
|---|---|
-G |
실효, 실제, 보조 그룹 ID만 씁니다. 여럿이면 빈칸으로 나눠 한 줄에 씁니다. |
-g |
실효 그룹 ID만 씁니다. |
-u |
실효 사용자 ID만 씁니다. |
-r |
실효 ID 대신 실제 ID를 씁니다. -g와 함께 쓰면 실제 그룹 ID를, -u와 함께 쓰면 실제 사용자 ID를 씁니다. |
-n |
-G, -g, -u와 함께 쓰면 ID 번호 대신 이름을 씁니다. |
-l |
실제나 실효 ID 대신 로그인 ID를 씁니다. -u와 함께 쓰면 로그인 UID를, -g와 함께 쓰면 로그인한 사용자의 기본 그룹 ID를 씁니다. 사용자 이름을 함께 주면 로그인 ID 대신 그 사용자의 ID를 보여 줍니다. |
| User | id에 줄 사용자의 로그인 이름입니다. 없으면 id를 부른 사용자입니다. |
영어 원문
The contents and format of the message written by the id command can be altered with the following flags:
-G— Specifies that the id command write the effective, real, and supplementary group IDs only. If there are multiple entries for the effective, real, or supplementary IDs, they are separated by a space and placed on the same line.-g— Specifies that the id command write only the effective group ID.-u— Specifies that the id command write only the effective user ID.-r— Specifies that the id command write the real ID instead of the effective ID. This flag can be invoked with either the-gflag to write the real group ID, or the-uflag to write the real user ID.-n— Specifies that the id command outputs the name, instead of the ID number, when it is specified with the-G,-g, and-uflags.-l— Specifies that the id command write the login ID instead of the real or effective ID. This flag can be invoked with either the-uflag to write the login UID or the-gflag to write the primary group ID for the login user. When username is passed with the-loption, the id command displays the ID details of the user name instead of the login ID details.- User — Specifies the login name of a user for the id command. If no user is specified, the user invoking the id command is the default.
보안
접근 제어: 이 프로그램은 TCB(Trusted Computing Base)에 일반 사용자 프로그램으로 설치해야 합니다.
영어 원문
Access Control: This program should be installed as a normal user program in the Trusted Computing Base.
종료 상태
| 값 | 뜻 |
|---|---|
| 0 | 잘 끝났습니다. |
| 0보다 큼 | 오류가 났습니다. |
영어 원문
This command returns the following exit values:
- 0 — Successful completion.
>0— An error occurred.
예제
- 현재 사용자의 시스템 ID를 모두 보여 줍니다.
id
uid=1544(sah) gid=300(build) euid=0(root) egid=9(printq) groups=0(system),10(audit)
이 예에서 사용자 이름은 sah(ID 1544), 기본 그룹은 build(300), 실효 사용자는 root(0), 실효 그룹은 printq(9), 보조 그룹은 system(0)과 audit(10)입니다.
- 현재 사용자의 모든 그룹 ID 번호를 보여 줍니다.
sah는 system(0), audit(10), build(300), printq(9) 그룹의 구성원입니다.
id -G
0 10 300 9
- 현재 사용자의 모든 그룹 이름을 보여 줍니다.
-n은 번호 대신 이름만 씁니다.
id -Gn
system audit build printq
- 현재 사용자의 실제 그룹 이름을 보여 줍니다.
id -gnr
build
- root로 로그인한 뒤
su로 사용자sah가 되었을 때 로그인 UID를 보여 줍니다.
id -lu
0
- 실제로 로그인한 사용자의 기본 그룹 이름을 보여 줍니다.
id -lgn
system
- 실제로 로그인한 사용자의 기본 그룹 ID를 보여 줍니다.
id -lg
0
영어 원문
- To display all system identifications for the current user, enter:
id
Output for the id command is displayed in the following format: uid=1544(sah) gid=300(build) euid=0(root) egid=9(printq) groups=0(system),10(audit)
In this example, the user has user name sah with an ID number of 1544; a primary group name of build with an ID number of 300; an effective user name of root with an ID number of 0; an effective group name of printq with an ID number of 9; and two supplementary group names of system and audit, with ID numbers 0 and 10, respectively.
- To display all group ID numbers for the current user, enter:
id -G
Output is displayed in the following format: 0 10 300 9
The -G flag writes only the group IDs for a user. In this example, user sah is a member of the system (0), audit (10), build (300), and printq (9) groups.
- To display all group names for the current user, enter:
id -Gn
Output is displayed in the following format: system audit build printq
The -n flag writes only the names instead of the ID numbers.
- To display the real group name for the current user, enter:
id -gnr
Output is displayed in the following format: build
- To display the login UID after logging in as root and running the su command to user sah, type:
id -lu
Output is displayed in the following format: 0
- To display the primary group name of the user who actually logged in, type:
id -lgn
Output is displayed in the following format: system
- To display the primary group ID of the user who actually logged in, type:
id -lg
Output is displayed in the following format:
0
파일
| 파일 | 설명 |
|---|---|
/usr/bin/id |
id 명령이 들어 있습니다. |
관련 명령어: login, getty, su
영어 원문
- /usr/bin/id — Contains the id command.
Related reference:
- login Command
Related information:
- getty command
- setgroups command
- su command
리눅스(GNU)와 다른 점
| 항목 | AIX 5.3·6.1 | GNU id |
|---|---|---|
-l |
로그인 UID(su 전의 사용자) | 없음(리눅스는 /proc/self/loginuid나 logname) |
| 출력 | euid=, egid=를 따로 표시 |
같음 |
AIX 5.3·6.1 문서에는 -Z(보안 문맥), -z(NUL 구분) 같은 GNU 옵션이 없습니다.