chitab 명령어 (AIX 5.3·6.1)
https://archive.horanglab.com/posts/aix-cmd-chitab
핵심 정리
/etc/inittab의 레코드를 바꿉니다. 식별자로 바꿀 레코드를 찾아 새Identifier:RunLevel:Action:Command전체로 바꿉니다.- 식별자 자체는 바꿀 수 없습니다. 이름을 바꾸려면
rmitab으로 지우고mkitab으로 다시 만듭니다. - 레코드를 주석 처리할 수는 없습니다. 실행하지 않게 하려면 Action을
off로 바꿉니다. - 공백이나 탭이 있으면 따옴표로 감쌉니다. 바꾼 뒤
init q로 다시 읽게 합니다.
| 항목 | 내용 |
|---|---|
| 버전 | AIX 5.3, AIX 6.1 (6.1 문서에 RBAC 보안 안내가 더해짐. 사용법은 같음) |
| 원문 | IBM Commands Reference — 5.3 Volume 1, 6.1 Volume 1 |
| 파일 | /usr/sbin/chitab, /etc/inittab |
| 관련 명령어 | lsitab, mkitab, rmitab, init, telinit |
목적
/etc/inittab 파일의 레코드를 바꿉니다.
영어 원문
Changes records in the /etc/inittab file.
구문
chitab { Identifier : RunLevel : Action : Command }
5.3 구문은 각 필드를 대괄호로 감싸 { [ Identifier ] : [ RunLevel ] : [ Action ] : [ Command ] }로 적습니다.
설명
chitab 명령은 /etc/inittab 파일의 레코드를 바꿉니다. Identifier:RunLevel:Action:Command 매개변수 문자열이 새 항목입니다. 매개변수 문자열의 Identifier 부분으로 특정 레코드를 찾을 수 있으며, 명령은 지정한 Identifier를 찾아 그 레코드를 바꿉니다.
참고: chitab으로 /etc/inittab의 항목을 주석 처리할 수는 없습니다.
영어 원문
The chitab command changes a record in the /etc/inittab file. The Identifier:Run Level:Action:Command parameter string is the new entry to the /etc/inittab file. You can search for a specific record by using fields in the Identifier portion of the parameter string. The command finds the specified Identifier and changes that record.
Note: The chitab command can not comment out an entry in the /etc/inittab file.
매개변수
/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이 콘솔에 접근하기 전에 프로세스를 시작합니다. 예를 들어 장치를 초기화할 때 씁니다. |
디스크 없는(diskless) 환경에서는 wait 동작을 쓰면 부팅이 빨라집니다(chitab 문서에만 있는 설명).
영어 원문
The Identifier:Run Level:Action:Command parameter string specifies a record in the /etc/inittab file where the following parameters apply:
- Action — A 20-character parameter that informs the init command how to process the Command parameter you specify. The init command recognizes the following actions: 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. 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. initdefault Start the process identified in this record only when the init command is originally invoked. The init command uses this line to determine which run level to originally enter. It does this by taking the highest run level specified in the RunLevel field and using that as its initial state. If the RunLevel parameter is empty, this 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 /etc/inittab file, it requests an initial run level from the operator at initial program load (IPL) time. 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. 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. 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. 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. 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. 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. 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. If you are operating in a diskless environment, specifying the wait action causes your system to boot more quickly.
- Command — A 1024-character field specifying the shell command.
- 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.
보안
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.
예제
tty2 레코드의 실행 수준을 바꿉니다. 더하는 레코드에 공백이나 탭이 있으면 따옴표가 꼭 필요합니다.
chitab "tty002:23:respawn:/usr/sbin/getty /dev/tty"
자주 쓰는 형태:
lsitab rcnfs # 지금 레코드 확인
chitab "rcnfs:23456789:off:/etc/rc.nfs > /dev/console 2>&1" # 부팅 때 NFS 시작을 끔
init q # init에 inittab을 다시 읽게 함
영어 원문
To change the run level of a record for tty2, enter: chitab "tty002:23:respawn:/usr/sbin/getty /dev/tty"
The quotes are required when the record being added has spaces or tabs.
파일
| 파일 | 설명 |
|---|---|
/etc/inittab |
init 명령이 시작할 프로세스를 나타냄 |
영어 원문
- /etc/inittab — Indicates which processes the init command starts.
Related information:
- init command
- lsitab command
- mkitab command
- rmitab command
리눅스(GNU)와 다른 점
리눅스는 대부분 systemd를 써서 /etc/inittab이 없거나 쓰이지 않습니다. 부팅 때 실행할 것은 systemd 단위(systemctl enable), 다시 살리는 서비스는 단위의 Restart=always, 기본 실행 수준은 systemctl set-default multi-user.target으로 정합니다. SysV init을 쓰는 오래된 배포판에서는 /etc/inittab을 편집기로 직접 고치고 telinit q로 다시 읽게 합니다.