리눅스 systemd와 유닛
유닛
유닛이란
-systemd 에서 시스템 자원과 서비스를 나타내기 위해 도입한 개념
-즉, 유닛은 systemd가 관리하는 시스템 자원이나 서비스와 같은 시스템 구성요소를 의미한다.
-유닛 설정 파일 또는 유닛 파일 로 표현되며
-유닛의 동작, 의존성, 실행 옵션 등은 '유닛 설정 파일'에서 설정 항목으로 제어된다.
-systemd 등장 이전에는 없었던 개념
유닛의 유형
| 유닛 유형 | 유닉 설정 파일 확장자 | 설명 |
|---|---|---|
| service | .service | 시스템 서비스로, 보통 데몬에 해당한다. |
| device | .device | 커널이 인식한 디바이스 파일 |
| mount | .mount | 파일 시스템 마운트 지점 |
| path | .path | 파일 시스템의 파일 또는 디렉터리 |
| socket | .sockiet | 프로세스 간 통신에 사용되는 소켓 |
| snapshot | .snapshot | 저장된 시스템의 상태 |
| target | .target | 특정 작업이나 서비스, 유닛의 그룹을 구성하는 데 사용되는 유닛 다양한 유닛을 포함하거나 그룹화할 수 있는 추상적 유닛 이들을 통해 작업이나 특정 상태를 그룹을 구성한다. |
유닛 파일이 존재하는 디렉터리
| 디렉터리 | 설명 |
|---|---|
| /usr/lib/systemd/system/ | 소프트웨어 패키지를 설치할 때 함께 설치된 유닛 파일 |
| /run/systemd/system/ | 런타임 시 만들어진 유닛 파일. 즉, 임시 유닛 파일. |
| /etc/systemd/system/ | systemctl enable(자동시작)을 이용해 만들어진 유닛 파일. 우선 순위가 가장 높은 디렉터리다. 윈도우의 사용자설정 시작프로그램의 느낌. |
유닛파일 까보기
service - rescue.service
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
[Unit]
Description=Rescue Shell
Documentation=man:sulogin(8)
DefaultDependencies=no
Conflicts=shutdown.target
After=sysinit.target plymouth-start.service
Before=shutdown.target
[Service]
Environment=HOME=/root
WorkingDirectory=-/root
ExecStartPre=-/usr/bin/plymouth --wait quit
ExecStart=-/usr/lib/systemd/systemd-sulogin-shell rescue
Type=idle
StandardInput=tty-force
StandardOutput=inherit
StandardError=inherit
KillMode=process
IgnoreSIGPIPE=no
SendSIGHUP=yes
device - 못찾음
mount
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
[Unit]
Description=Temporary Directory /tmp
Documentation=...
Documentation=man:file-hierarchy(7)
Documentation=...
ConditionPathIsSymbolicLink=!/tmp
DefaultDependencies=no
Conflicts=umount.target
Before=local-fs.target umount.target
After=swap.target
[Mount]
What=...
Where=...
Type=...
Options=...
# Make 'systemctl enable tmp.mount' work:
[Install]
WantedBy=...
path - systemd-ask-password-wall.path
1
2
3
4
5
6
7
8
9
10
11
12
13
14
[Unit]
Description=Forward Password Requests to Wall Directory Watch
Documentation=man:systemd-ask-password-wall.path(8)
DefaultDependencies=no
Before=paths.target cryptsetup.target
Conflicts=emergency.service
Before=emergency.service
Conflicts=shutdown.target
Before=shutdown.target
[Path]
DirectoryNotEmpty=/path/to/ask-pass
MakeDirectory=yes
socket - sshd.socket
1
2
3
4
5
6
7
8
9
10
11
[Unit]
Description=OpenSSH Server Socket
Documentation=man:sshd(8) man:sshd_config(5)
Conflicts=sshd.service
[Socket]
ListenStream=*****
Accept=*****
[Install]
WantedBy=sockets.target
snapshot - 못찾음
target - 특징적인 것을 찾지 못함
Reference
// reading compass
이 글과 이어지는 경로
시리즈, 카테고리, 태그 겹침, 최신도를 점수화해 가까운 글일수록 중심에 배치합니다.
댓글 남기기