mkitab 명령어 (AIX 5.3·6.1)
https://archive.horanglab.com/posts/aix-cmd-mkitab
핵심 정리
/etc/inittab에 레코드를 더합니다. 형식은Identifier:RunLevel:Action:Command이며, 공백이 있으면 따옴표로 감쌉니다.- 기본으로는 파일 끝에 더하고,
-i 식별자를 주면 그 레코드 바로 뒤에 넣습니다. 순서가 중요할 때(예:srcmstr뒤에rctcpip) 씁니다. - 자주 쓰는 Action:
respawn(죽으면 다시 시작),wait(끝날 때까지 기다림),once(한 번 시작),off(끔). - 시스템 파일이 망가지지 않게 Command의 표준 입출력은 리디렉션으로 정해 주는 것이 좋습니다(예:
> /dev/console 2>&1). - 더한 뒤 바로 반영하려면
init q(또는telinit q)로init에 다시 읽게 합니다.
| 항목 | 내용 |
|---|---|
| 버전 | AIX 5.3, AIX 6.1 (6.1 문서에 RBAC 보안 안내가 더해짐. 사용법은 같음) |
| 원문 | IBM Commands Reference — 5.3 Volume 3, 6.1 Volume 3 |
| 파일 | /usr/sbin/mkitab, /etc/inittab |
| 관련 명령어 | lsitab, chitab, rmitab, init, telinit |
목적
/etc/inittab 파일에 레코드를 만듭니다.
영어 원문
Makes records in the /etc/inittab file.
구문
mkitab [ -i Identifier ] { [ Identifier ] : [ RunLevel ] : [ Action ] : [ Command ] }
설명
mkitab 명령은 /etc/inittab 파일에 레코드를 더합니다. Identifier:RunLevel:Action:Command 매개변수 문자열이 새 항목입니다. -i Identifier 플래그를 쓰면 특정 레코드 뒤에 넣을 수 있습니다. 명령은 지정한 Identifier 필드를 찾아 그 레코드 뒤에 새 레코드를 넣습니다.
영어 원문
The mkitab command adds a record to the /etc/inittab file. The Identifier:RunLevel:Action:Command parameter string specifies the new entry to the /etc/inittab file. You can insert a record after a specific record using the -i Identifier flag. The command finds the field specified by the Identifier parameter and inserts the new record after the one identified by the -i Identifier flag.
매개변수
/etc/inittab 레코드는 Identifier:RunLevel:Action:Command 형식입니다.
| 필드 | 뜻 |
|---|---|
| Identifier | 레코드를 하나로 구분하는 14자 이내의 이름. 겹치면 실패하며, 바꿀 수 없습니다(바꾸려 하면 실패). |
| RunLevel | 이 레코드를 처리할 실행 수준(20자 이내). init이 시작하는 프로세스마다 실행 수준을 하나 이상 줄 수 있습니다. |
| Action | init이 Command를 어떻게 처리할지 알려 주는 값(20자 이내, 아래 표). |
| Command | 실행할 셸 명령(1024자 이내). |
Action 값:
| Action | 뜻 |
|---|---|
respawn |
프로세스가 없으면 시작합니다. 있으면 아무것도 하지 않고 /etc/inittab을 계속 읽습니다. 끝나면 다시 시작합니다. |
wait |
그 실행 수준에 들어갈 때 프로세스를 시작하고 끝날 때까지 기다립니다. 같은 실행 수준에 있는 동안 다시 읽을 때는 이 레코드를 무시합니다. |
once |
그 실행 수준에 들어갈 때 프로세스를 시작하고 기다리지 않으며, 끝나도 다시 시작하지 않습니다. 실행 중에 새 실행 수준으로 바뀌어도 다시 시작하지 않습니다. |
boot |
시스템이 부팅하며 /etc/inittab을 읽을 때만 처리합니다. 프로세스를 시작하고 기다리지 않으며, 끝나도 다시 시작하지 않습니다. 실행 수준은 기본값이거나 시작 때 init이 정한 실행 수준과 같아야 합니다. |
bootwait |
부팅할 때만 처리합니다. 프로세스를 시작하고 끝날 때까지 기다리며, 끝나도 다시 시작하지 않습니다. |
powerfail |
init이 전원 장애 신호 SIGPWR을 받을 때만 시작합니다. |
powerwait |
SIGPWR을 받을 때만 시작하고, 끝날 때까지 기다린 뒤 /etc/inittab을 계속 처리합니다. |
off |
프로세스가 실행 중이면 경고 신호 SIGTERM을 보내고 20초 뒤 SIGKILL을 보냅니다. 없으면 이 줄을 무시합니다. |
hold |
프로세스가 끝나도 새로 시작하지 않습니다. phold 명령으로만 켤 수 있습니다. |
ondemand |
respawn과 같습니다. 실행 수준 a, b, c에서 respawn 동작을 하려면 이것을 씁니다. |
initdefault |
init이 처음 실행될 때만 처리하며, 처음 들어갈 실행 수준을 정합니다. RunLevel 필드의 가장 높은 실행 수준을 씁니다. RunLevel이 비어 있으면 0123456789로 보고 실행 수준 9로 들어갑니다. initdefault 줄이 없으면 IPL 때 운영자에게 실행 수준을 묻습니다. |
sysinit |
init이 콘솔에 접근하기 전에 프로세스를 시작합니다. 예를 들어 장치를 초기화할 때 씁니다. |
주의: 시스템 파일이 망가지지 않도록, Command 매개변수에서 stdin, stdout, stderr를 리디렉션으로 지정하거나 명령줄이 실행하는 프로그램이 직접 열어야 합니다.
영어 원문
The Identifier:RunLevel:Action:Command parameter string specifies the record in the /etc/inittab file, as follows:
- Identifier — A 14-character parameter that uniquely identifies an object. The Identifier must be unique. If the Identifier is not unique, the command is unsuccessful. The Identifier cannot be changed; if you try to change it, the command is unsuccessful.
- RunLevel — A 20-character parameter defining the run levels in which the Identifier can be processed. Each process started by the init command can be assigned one or more run levels in which it can be started.
- Action — A 20-character parameter that informs the init command how to process the Command parameter that you specify. The init command recognizes the following actions: respawn If the process identified in this record does not exist, start the process. If the process currently exists, do nothing and continue scanning the /etc/inittab file. wait When the init command enters the run level specified for this record, start the process and wait for it to stop. While the init command is in the same run level, all subsequent reads of the /etc/inittab file ignore this object. once When the init command enters the run level specified for this record, start the process, do not wait for it to stop and when it does stop do not restart the process. If the system enters a new run level while the process is running, the process is not restarted. boot Read this record only when the system boots and reads the /etc/inittab file. The init command starts the process. Do not wait for the process to stop and when it does stop, do not restart the process. The run level for this process should be the default, or it must match the run level specified by the init command at startup time. bootwait Read this record only when the system boots and reads the /etc/inittab file. The init command starts the process. Wait for it to stop, and when it does stop, do not restart the process. powerfail Start the process identified in this record only when the init command receives a SIGPWR power fail signal. powerwait Start the process identified in this record only when the init command receives a SIGPWR power fail signal, and wait until it stops before continuing to process the /etc/inittab file. off If the process identified in this record is currently running, send the warning signal SIGTERM and wait 20 seconds before sending the SIGKILL kill signal. If the process is nonexistent, ignore this line. hold When the process identified in this record is terminated, do not start a new one. The hold action can only be activated by the phold command. ondemand Functionally identical to respawn. If the process identified in this record does not exist, start the process. If the process currently exists, do nothing and continue scanning the /etc/inittab file. Specify this action to perform the respawn action when using a, b, or c run levels. initdefault A line with this action is processed only when the init command is originally invoked. The init command uses this line to determine which run level to originally enter. The command does this by taking the highest run level specified in the RunLevel parameter and using that as the command's initial state. If the RunLevel parameter is empty, its value is interpreted as 0123456789, and the init command enters a run level of 9. If the init command does not find an initdefault line in the inittab file, it requests an initial run level from the operator at initial program load (IPL) time. sysinit Start the process identified in this record before the init command tries to access the console. For example, you might use this to initialize devices.
- Command — A 1024-character field specifying the shell command. Attention: To avoid possible corruption of system files, the stdin, stdout, and stderr files must be specified in the Command parameter with redirection, or they must be explicitly opened by the program being run by the command line.
플래그
| 플래그 | 설명 |
|---|---|
-i Identifier |
새 레코드를 /etc/inittab의 어느 레코드 뒤에 둘지 정합니다. |
영어 원문
-iIdentifier — Specifies which record in the /etc/inittab file the new record follows.
보안
RBAC 사용자와 Trusted AIX 사용자는 주의하세요. 이 명령은 특권 작업을 할 수 있으며, 특권 작업은 특권 사용자만 할 수 있습니다. 특권과 권한 목록은 lssecattr 명령이나 getcmdattr 하위 명령으로 봅니다(6.1 문서에만 있음).
영어 원문
Attention RBAC users and Trusted AIX users: This command can perform privileged operations. Only privileged users can run privileged operations. For more information about authorizations and privileges, see Privileged Command Database in Security. For a list of privileges and the authorizations associated with this command, see the lssecattr command or the getcmdattr subcommand.
예제
init이 tty2의 로그인을 처리하게 하는 레코드를 더합니다.
mkitab "tty002:2:respawn:/usr/sbin/getty /dev/tty2"
/usr/sbin/srcmstr가 시작된 뒤/etc/rc.tcpip을 실행하게 하는 레코드를srcmstr레코드 뒤에 더합니다.
mkitab -i srcmstr "rctcpip:2:wait:/etc/rc.tcpip > /dev/console"
/etc/rc를 실행하고 그 출력을 부팅 로그에 보내는 레코드를 더합니다.
mkitab "rc:2:wait:/etc/rc 2>&1 | alog -tboot > /dev/console"
자주 쓰는 형태:
# 부팅 때 응용 프로그램 시작 스크립트를 한 번 실행(rc.tcpip 뒤에)
mkitab -i rctcpip "rcapp:2:once:/etc/rc.app > /dev/console 2>&1"
lsitab rcapp # 들어갔는지 확인
init q # init에 inittab을 다시 읽게 함
영어 원문
To add a new record to the /etc/inittab file, telling the init command to handle a login on tty2, type:
mkitab "tty002:2:respawn:/usr/sbin/getty /dev/tty2"To add a new record to the /etc/inittab file, telling the init command to execute the /etc/rc.tcpip file after the /usr/sbin/srcmstr file is started, type:
mkitab -i srcmstr "rctcpip:2:wait:/etc/rc.tcpip > /dev/console"To add a new record to the /etc/inittab file, telling the init command to execute the /etc/rc file and send its output to the boot log, type:
mkitab ((rc:2:wait:/etc/rc 2>&1 | alog -tboot > /dev/console))
파일
| 파일 | 설명 |
|---|---|
/etc/inittab |
init 명령이 시작할 프로세스를 나타냄 |
영어 원문
- /etc/inittab — Contains the mkitab command.
Related information:
- chitab command
- init command
- /etc/inittab file
리눅스(GNU)와 다른 점
리눅스는 대부분 systemd를 써서 /etc/inittab이 없거나 쓰이지 않습니다. 부팅 때 실행할 것은 systemd 단위(systemctl enable), 다시 살리는 서비스는 단위의 Restart=always, 기본 실행 수준은 systemctl set-default multi-user.target으로 정합니다. SysV init을 쓰는 오래된 배포판에서는 /etc/inittab을 편집기로 직접 고치고 telinit q로 다시 읽게 합니다.