systemctl
은 systemd의 services 전반적인 설정에 필수적인 명령# root 용 service, timer daemon
$ sudo systemctl [--system] [option] [service | timer]
# user 용 service, timer daemon
$ systemctl --user [option] [service | timer]
command | description |
---|---|
systemctl list-unit-files [pattern] | 설치된 Unit 목록확인 |
systemctl enable unit | unit이 부팅 시 자동 활성화 |
systemctl disable unit | unit이 부팅 시 자동활성화 되는 것 방지 |
systemctl isolate target | target 의 실행모드 변경 |
systemctl start unit | unit 을 즉시 활성화 |
systemctl stop unit | unit 을 즉시 비활성화 |
systemctl restart unit | unit 을 재시작. 실행되지 않은 상태였다면 start |
systemctl reload unit | ★ ★설정 을 바꿧으면 reload로 재구동 ★ ★ 유닛 설정 파일만 리로드 |
systemctl status unit | unit 의 상태 및 최근 로그 내용 확인 |
systemctl kill pattern | pattern 에 일치하는 unit에 시그널 보냄 |
systemctl daemon-reload | unit 파일들과 systemd 설정 정보들을 다시 로드 |
-p UnitPath show
: Pathpkg-config
설정에서 나온 것이다.$ sudo systemctl -p UnitPath show
UnitPath=/etc/systemd/system.control \
/run/systemd/system.control \
/run/systemd/transient \
/run/systemd/generator.early \
/etc/systemd/system \
/etc/systemd/system.attached \
/run/systemd/system \
/run/systemd/system.attached \
/run/systemd/generator \
/usr/local/lib/systemd/system \
/lib/systemd/system \
/usr/lib/systemd/system \
/run/systemd/generator.late
$ pkg-config systemd --variable=systemdsystemunitdir
/lib/systemd/system
$ pkg-config systemd --variable=systemdsystemconfdir
/etc/systemd/system
status <service>
media.mount
'에 대해 조회해본다.$ systemctl status media.mount
media.mount - Media Directory
Loaded: loaded (/usr/lib/systemd/system/media.mount; static)
Active: active (mounted) since Wed, 13 May 2015 11:14:55 -0800; 37min ago
Where: /media
What: tmpfs
Process: 311 ExecMount=/bin/mount tmpfs /media -t tmpfs -o \
mode=755,nosuid,nodev,noexec (code=exited, status=0/SUCCESS)
CGroup: name=systemd:/system/media.mount
code=exited
status=0/SUCCESS
$ systemctl status NetworkManager
● NetworkManager.service - Network Manager
Loaded: loaded (/lib/systemd/system/NetworkManager.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2021-09-27 10:22:14 KST; 3h 45min ago
Docs: man:NetworkManager(8)
Main PID: 1512 (NetworkManager)
Tasks: 3 (limit: 4600)
Memory: 12.1M
CGroup: /system.slice/NetworkManager.service
└─1512 /usr/sbin/NetworkManager --no-daemon
Sep 27 10:22:14 ubuntu-linux-20-04-desktop NetworkManager[1512]: <info> [1632705734.9646] ifupdown: interface-parser: finished parsing file /etc/network/interfaces
Sep 27 10:22:14 ubuntu-linux-20-04-desktop NetworkManager[1512]: <info> [1632705734.9678] device (lo): carrier: link connected
Sep 27 10:22:14 ubuntu-linux-20-04-desktop NetworkManager[1512]: <info> [1632705734.9680] manager: (lo): new Generic device (/org/freedesktop/NetworkManager/Devices/1)
Sep 27 10:22:14 ubuntu-linux-20-04-desktop NetworkManager[1512]: <info> [1632705734.9686] device (eth0): carrier: link connected
Sep 27 10:22:14 ubuntu-linux-20-04-desktop NetworkManager[1512]: <info> [1632705734.9691] manager: (eth0): new Ethernet device (/org/freedesktop/NetworkManager/Devices/2)
Sep 27 10:22:14 ubuntu-linux-20-04-desktop NetworkManager[1512]: <warn> [1632705734.9723] Error: failed to open /run/network/ifstate
Sep 27 10:22:14 ubuntu-linux-20-04-desktop NetworkManager[1512]: <info> [1632705734.9770] manager: startup complete
Sep 27 10:22:14 ubuntu-linux-20-04-desktop NetworkManager[1512]: <info> [1632705734.9936] modem-manager: ModemManager not available
Sep 27 10:22:15 ubuntu-linux-20-04-desktop NetworkManager[1512]: <info> [1632705735.0191] modem-manager: ModemManager now available
Sep 27 10:22:39 ubuntu-linux-20-04-desktop NetworkManager[1512]: <info> [1632705759.0607] agent-manager: agent[269aca200e3dea6f,:1.143/org.gnome.Shell.NetworkAgent/1000]: agent registered
CGroup
에서 '제어 그룹 프로세스 트리'를 볼 수 있다.list-units
: loaded && active 인 서비스들 조회$ systemctl list-units
--all list-units
: loaded && (active || inactive) 인 서비스들 조회$ systemctl --all list-units
list-unit-files
: 설치되어 있으면 전부 출력$ systemctl list-unit-files
list-units
: Loaded, active$ systemctl list-units
--all list-units
: Loaded, {,in}active$ systemctl --all list-units
list-unit-files
: every Units$ systemctl list-unit-files
-t service
$ systemctl -t service list-units
-t service
installed unit$ systemctl -t service list-unit-files
show -p <type> unit
: 종속성$ sudo systemctl show -p <type> <unit>
<unit>
에 대해 <type>
의 종속성을 체크함$ systemctl show -p WantedBy apt-daily.service
WantedBy=
$ systemctl show -p Type apt-daily.service
Type=oneshot
$ sudo systemctl enable <UNIT>
$ sudo systemctl disable <UNIT>
$ systemctl list-timers
systemd --system
용 저널 로그$ journalctl -r -u <service_name.service>
systemd --user
용 저널 로그$ journalctl --user
$ journalctl --user-unit <specific user service.service>