who 명령어 (AIX 5.3·6.1)
https://archive.horanglab.com/posts/aix-cmd-who
핵심 정리
- 지금 로컬 시스템에 로그인한 사용자의 로그인 이름, tty, 로그인 시각을 보여 줍니다. 원격 로그인이면 호스트 이름도 보입니다.
who am i(who -m)는 자신의 정보만 보여 줍니다.- 기본으로
/etc/utmp를 읽고, 파일을 주면 그 파일을 읽습니다.who /var/adm/wtmp는 로그인 기록,who /etc/security/failedlogin은 실패한 로그인 기록입니다. -b(마지막 부팅 시각),-r(실행 수준),-u(유휴 시간과 PID),-q(사용자 수),-H(머리글),-T(쓰기 가능 여부),-a(모두).-X는 8자보다 긴 사용자 이름을 자르지 않고 마지막 열에 보여 줍니다.- 로컬 노드의 사용자만 보여 줍니다. AIX 5.3과 6.1 문서의 내용이 같습니다.
| 항목 | 내용 |
|---|---|
| 버전 | AIX 5.3, AIX 6.1 (두 버전 내용 같음) |
| 원문 | IBM Commands Reference — 5.3 Volume 6, 6.1 Volume 6 |
| 파일 | /etc/utmp, /var/adm/wtmp, /etc/security/failedlogin |
| 관련 명령어 | w, whoami, last, date |
목적
지금 시스템을 쓰고 있는 사용자를 보여 줍니다.
영어 원문
Identifies the users currently logged in.
구문
who [ -a | -b -d -i -l -m -p -q -r -s -t -u -w -A -H -T -X ] [ File ]
who am { i | I }
설명
who 명령은 지금 로컬 시스템에 있는 모든 사용자의 정보(로그인 이름, tty, 로그인 날짜와 시각)를 보여 줍니다. who am i나 who am I를 입력하면 자신의 로그인 이름, tty, 로그인한 날짜와 시각을 보여 줍니다. 원격 컴퓨터에서 로그인했으면 그 컴퓨터의 호스트 이름도 보여 줍니다.
줄에서 활동이 있은 뒤 지난 시간, 명령 해석기(셸)의 프로세스 ID, 로그인·로그오프·재시작·시스템 시계 변경, 초기화 프로세스가 만든 다른 프로세스도 보여 줄 수 있습니다.
출력의 일반 형식은 다음과 같습니다.
Name [State] Line Time [Activity] [Pid] [Exit] (Hostname)
| 항목 | 뜻 |
|---|---|
| Name | 사용자의 로그인 이름 |
| State | 누구나 그 줄에 쓸 수 있는지(-T 참고) |
| Line | /dev 디렉터리에 있는 줄 이름 |
| Time | 로그인한 시각 |
| Activity | 그 사용자의 줄에서 마지막 활동 뒤 지난 시와 분. .(점)은 최근 1분 안의 활동, 24시간 넘게 조용했거나 시스템 시작 뒤 쓰지 않았으면 old |
| Pid | 사용자 로그인 셸의 프로세스 ID |
| Term | 프로세스 종료 상태(-d 참고). 값은 wait 서브루틴이나 /usr/include/sys/signal.h를 봅니다. |
| Exit | 끝난 프로세스의 종료 상태(-d 참고) |
| Hostname | 사용자가 로그인한 컴퓨터의 이름 |
who는 보통 /etc/utmp 파일을 살펴 정보를 얻습니다. File 매개변수로 다른 파일을 주면 그 파일을 살펴보며, 보통 /var/adm/wtmp나 /etc/security/failedlogin입니다. 파일 이름을 여럿 주면 마지막 것만 씁니다.
참고: 로컬 노드의 사용자만 알아냅니다.
영어 원문
The who command displays information about all users currently on the local system. The following information is displayed: login name, tty, date and time of login. Typing who am i or who am I displays your login name, tty, date and time you logged in. If the user is logged in from a remote machine, then the host name of that machine is displayed as well.
The who command can also display the elapsed time since line activity occurred, the process ID of the command interpreter (shell), logins, logoffs, restarts, and changes to the system clock, as well as other processes generated by the initialization process.
The general output format of the who command is as follows: Name [State] Line Time [Activity] [Pid] [Exit] (Hostname)
where:
Name— Identifies the user's login name.State— Indicates whether the line is writable by everyone (see the-Tflag).Line— Identifies the line name as found in the /dev directory.Time— Represents the time when the user logged in.Activity— Represents the hours and minutes since activity last occurred on that user's line. A . (dot) here indicates line activity within the last minute. If the line has been quiet more than 24 hours or has not been used since the last system startup, the entry is marked as old.Pid— Identifies the process ID of the user's login shell.Term— Identifies the process termination status (see the-dflag). For more information on the termination values, refer to the wait subroutine or to the /usr/include/sys/signal.h file.Exit— Identifies the exit status of ended processes (see the-dflag).Hostname— Indicates the name of the machine the user is logged in from.
To obtain information, the who command usually examines the /etc/utmp file. If you specify another file with the File parameter, the who command examines that file instead. This new file is usually the /var/adm/wtmp or /etc/security/failedlogin file.
If the File parameter specifies more than one file name, only the last file name will be used.
Note: This command only identifies users on the local node.
플래그
| 플래그 | 설명 |
|---|---|
-a |
/etc/utmp나 지정한 파일을 모든 정보로 처리합니다. -bdlprtTu를 지정한 것과 같습니다. |
-b |
가장 최근의 시스템 시작 날짜와 시각을 보여 줍니다. |
-d |
init이 다시 만들지 않은 채 끝난 프로세스를 모두 보여 줍니다. 죽은 프로세스에는 Exit 열에 종료 값(wait가 돌려준 값)이 나옵니다. 응용 프로그램이 돌려준 오류 번호로 프로세스가 왜 끝났는지 볼 때 좋습니다. |
-l |
로그인 프로세스를 나열합니다. |
-m |
현재 터미널의 정보만 보여 줍니다. who am i, who am I와 같습니다. |
-p |
init이 만든, 지금 활성인 프로세스를 나열합니다. |
-q |
로컬 시스템의 사용자와 사용자 수를 간단히 출력합니다. |
-r |
현재 실행 수준을 보여 줍니다. |
-s |
이름, 줄, 시각 필드만 나열합니다. 기본이므로 who와 who -s는 같습니다. |
-t |
root가 date 명령으로 시스템 시계를 마지막으로 바꾼 때를 보여 줍니다. 설치 뒤 date를 실행한 적이 없으면 출력이 없습니다. |
-u, -i |
현재 사용자마다 사용자 이름, tty, 로그인 시각, 줄 활동, 프로세스 ID를 보여 줍니다. |
-A |
/etc/utmp의 모든 회계 항목을 보여 줍니다. 이 항목은 acctwtmp 명령이 만듭니다. |
-H |
머리글(제목)을 보여 줍니다. |
-T, -w |
tty의 상태와 누가 그 tty에 쓸 수 있는지 보여 줍니다. +는 누구나, -는 root나 소유자만, ?는 잘못된 줄입니다. |
-X |
사용자 이름을 앞 8자로 자르지 않고 모두 출력하며, 사용자 이름을 출력의 마지막 열로 옮깁니다. |
영어 원문
-a— Processes the /etc/utmp file or the named file with all information. Equivalent to specifying the-bdlprtTuflags.-b— Indicates the most recent system startup time and date.-d— Displays all processes that have expired without being regenerated by init. The exit field appears for dead processes and contains the termination and exit values (as returned by wait) of the dead process. (This flag is useful for determining why a process ended by looking at the error number returned by the application.)-l— Lists any login process.-m— Displays information about the current terminal only. The who -m command is equivalent to the who am i and who am I commands.-p— Lists any active process that is currently active and has been previously generated by init.-q— Prints a quick listing of users and the number of users on the local system.-r— Indicates the current run-level of the process.-s— Lists only the name, line, and time fields. This flag is the default; thus, the who and who -s commands are equivalent.-t— Indicates the last change to the system clock by the root user using the date command. If the date command has not been run since system installation, the who -t command produces no output.-uor-i— Displays the user name, tty, login time, line activity, and process ID of each current user.-A— Displays all accounting entries in the /etc/utmp file. These entries are generated through the acctwtmp command.-H— Displays a header (title).-Tor-w— Displays the state of the tty and indicates who can write to that tty as follows:+Writable by anyone.-Writable only by the root user or its owner. ? Bad line encountered.-X— Prints all available characters of each user name instead of truncating to the first 8 characters. The user name is also moved to the last column of the output.
종료 상태
| 값 | 뜻 |
|---|---|
| 0 | 잘 끝났습니다. |
| 0보다 큼 | 오류가 났습니다. |
영어 원문
This command returns the following exit values:
- 0 — Successful completion.
>0— An error occurred.
예제
- 로컬 시스템 노드를 쓰고 있는 사람을 보여 줍니다.
who
pts/1 Nov 9 00:20 long_username_greater_than_eight_characters (localhost)
- 자신의 사용자 이름을 보여 줍니다.
who am i
george lft/0 Jun 8 08:34
- 로그인, 로그아웃, 시스템 시작과 종료의 기록을 보여 줍니다.
who /var/adm/wtmp
hank lft/0 Jun 8 08:34 (ausnix5)
john lft/0 Jun 8 08:34 (JIKey)
mary lft/0 Jun 8 08:22 (machine.austin.ibm)
jan pts4 Jun 8 09:19 (puff.wisc.edu)
- 로컬 시스템 노드의 실행 수준을 보여 줍니다.
who -r
. run-level 2 Jun 8 04:15 2 0 s
- init이 만든, 지금 활성인 프로세스를 보여 줍니다.
who -p
srcmstr . Jun 8 04:15 old 2896
cron . Jun 8 04:15 old 4809
uprintfd . Jun 8 04:15 old 5158
/var/adm/wtmp를-bdlprtTu플래그로 처리합니다(출력 일부).
who -a /var/adm/wtmp
. system boot Jun 19 10:13
. run-level 2 Jun 19 10:13
rc - . Jun 19 10:13 old
srcmstr - . Jun 19 10:14 old
rctcpip - . Jun 19 10:14 old
cron - . Jun 19 10:16 old
qdaemon - . Jun 19 10:16 old
LOGIN - lft0 Jun 19 10:16 old
영어 원문
-
- To display information about who is using the local system node, type:
who
Information similar to the following is displayed:
pts/1 Nov 9 00:20 long_username_greater_than_eight_characters (localhost)
- To display your user name, type:
who am i
Information similar to the following is displayed: george lft/0 Jun 8 08:34
- To display a history of logins, logouts, system startups, and system shutdowns, type:
who /var/adm/wtmp
Information similar to the following is displayed: hank lft/0 Jun 8 08:34 (ausnix5) john lft/0 Jun 8 08:34 (JIKey) mary lft/0 Jun 8 08:22 (machine.austin.ibm) jan pts4 Jun 8 09:19 (puff.wisc.edu)
- To display the run-level of the local system node, type:
who -r
Information similar to the following is displayed: . run-level 2 Jun 8 04:15 2 0 s
- To display any active process that is currently actively and has been previously generated by init, type:
who -p
Information similar to the following is displayed: srcmstr . Jun 8 04:15 old 2896 cron . Jun 8 04:15 old 4809 uprintfd . Jun 8 04:15 old 5158
- To process the /var/adm/wtmp file with the
-bdlprtTuflags specified, type:
who -a /var/adm/wtmp
Information similar to the following is displayed:
. system boot Jun 19 10:13
. run-level 2 Jun 19 10:13
. . Jun 19 10:14 old
. . Jun 19 10:14 old
. . Jun 19 10:14 old
rc - . Jun 19 10:13 old
. . Jun 19 10:16 old
. . Jun 19 10:14 old
srcmstr - . Jun 19 10:14 old rctcpip - . Jun 19 10:14 old rcdce - . Jun 19 10:14 old rccm - . Jun 19 10:15 old dceupdt - . Jun 19 10:15 old rcnfs - . Jun 19 10:15 old cron - . Jun 19 10:16 old piobe - . Jun 19 10:16 old qdaemon - . Jun 19 10:16 old writesrv - . Jun 19 10:16 old uprintfd - . Jun 19 10:16 old
. . Jun 19 10:16 old
LOGIN - lft0 Jun 19 10:16 old
. . Jun 19 10:16 old
. . Jun 19 10:16 old
파일
| 파일 | 설명 |
|---|---|
/etc/utmp |
사용자와 회계 정보가 들어 있습니다. |
/etc/security/failedlogin |
잘못된 로그인의 기록이 모두 들어 있습니다. |
/var/adm/wtmp |
파일을 마지막으로 만든 뒤의 모든 로그인 기록이 들어 있습니다. |
/usr/include/sys/signal.h |
종료 값 목록이 들어 있습니다. |
관련 명령어: date
영어 원문
- /etc/utmp — Contains user and accounting information.
- /etc/security/failedlogin — Contains the history of all invalid logins.
- /var/adm/wtmp — Contains the history of all logins since the file was last created.
- /usr/include/sys/signal.h — Contains a list of termination values.
Related information:
- date command
- wait command
리눅스(GNU)와 다른 점
| 항목 | AIX 5.3·6.1 | 리눅스 who(coreutils) |
|---|---|---|
| 기록 파일 | /etc/utmp, /var/adm/wtmp, /etc/security/failedlogin |
/var/run/utmp, /var/log/wtmp, /var/log/btmp |
-X |
긴 사용자 이름을 자르지 않음 | 없음 |
-A |
회계 항목 | 없음 |
실패한 로그인은 AIX에서 who /etc/security/failedlogin으로, 리눅스에서 lastb로 봅니다.