728x90
systemd 명령어
systemd, init - systemd 시스템 및 서비스 관리자
systemd에서 서비스를 관리하는 명령어는 다음과 같습니다.
- systemctl list-unit-files --type=service - 현재 설치된 모든 서비스 목록을 출력합니다.
- systemctl start [서비스 이름] - 지정된 서비스를 시작합니다.
- systemctl stop [서비스 이름] - 지정된 서비스를 중지합니다.
- systemctl enable [서비스 이름] - 지정된 서비스를 부팅 시 자동으로 실행하도록 설정합니다.
- systemctl disable [서비스 이름] - 지정된 서비스를 부팅 시 자동으로 실행하지 않도록 설정합니다.
- systemctl status [서비스 이름] - 지정된 서비스의 상태를 출력합니다.
- journalctl -u [서비스 이름] - 지정된 서비스의 로그를 출력합니다.
현재 단위(units) 나열
systemctl list-units
UNIT | 시스템(systemd) 단위 이름 |
LOAD |
단위 정의가 제대로 로드되었는지 여부를 반영합니다.
|
ACTIVE | 상위 단위 활성화 상태, 즉 SUB의 일반화. |
SUB |
저수준 유닛 활성화 상태, 값은 유닛 유형에 따라 다릅니다.
|
DESCRIPTION | 단위가 무엇인지/하는 일에 대한 간단한 텍스트 설명입니다. |
systemctl list-units --all
systemctl list-units --all --state=inactive
systemctl list-units --type=service
모든 단위 파일(unit files) 나열
systemctl list-unit-files
단위(unit) 관리
systemctl cat sshd.service
$ systemctl cat sshd.service
# /lib/systemd/system/ssh.service
[Unit]
Description=OpenBSD Secure Shell server
Documentation=man:sshd(8) man:sshd_config(5)
After=network.target auditd.service
ConditionPathExists=!/etc/ssh/sshd_not_to_be_run
[Service]
EnvironmentFile=-/etc/default/ssh
ExecStartPre=/usr/sbin/sshd -t
ExecStart=/usr/sbin/sshd -D $SSHD_OPTS
ExecReload=/usr/sbin/sshd -t
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartPreventExitStatus=255
Type=notify
RuntimeDirectory=sshd
RuntimeDirectoryMode=0755
[Install]
WantedBy=multi-user.target
Alias=sshd.service
종속성 표시
systemctl list-dependencies sshd.service
단위(unit) 속성 확인
systemctl show sshd.service
단위(unit) 파일 편집
systemctl edit sshd.service
### Editing /etc/systemd/system/ssh.service.d/override.conf
### Anything between here and the comment below will become the new contents of the file
### Lines below this comment will be discarded
### /lib/systemd/system/ssh.service
# [Unit]
# Description=OpenBSD Secure Shell server
# Documentation=man:sshd(8) man:sshd_config(5)
# After=network.target auditd.service
# ConditionPathExists=!/etc/ssh/sshd_not_to_be_run
#
# [Service]
# EnvironmentFile=-/etc/default/ssh
# ExecStartPre=/usr/sbin/sshd -t
# ExecStart=/usr/sbin/sshd -D $SSHD_OPTS
# ExecReload=/usr/sbin/sshd -t
# ExecReload=/bin/kill -HUP $MAINPID
# KillMode=process
# Restart=on-failure
# RestartPreventExitStatus=255
# Type=notify
# RuntimeDirectory=sshd
# RuntimeDirectoryMode=0755
#
# [Install]
# WantedBy=multi-user.target
# Alias=sshd.service
Editing "/etc/systemd/system/ssh.service.d/override.conf" canceled: temporary file is empty.
기본 target 가져오기 및 설정
systemctl get-default
$ systemctl get-default
graphical.target
systemctl set-default graphical.target
systemctl rescue
systemctl halt
systemctl poweroff
systemctl reboot
참고URL
- systemd 시스템 및 서비스 관리자 : https://www.freedesktop.org/wiki/Software/systemd/
- systemd 서비스 list : https://scbyun.com/457
- fedoraproject DOCS : https://docs.fedoraproject.org/en-US/quick-docs/understanding-and-administering-systemd/index.html
- How To Use Systemctl to Manage Systemd Services and Units : https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units
728x90
'리눅스' 카테고리의 다른 글
CentOS 7에서 고정 IP를 설정하는 방법 (0) | 2022.12.12 |
---|---|
CentOS 7에서 yum 저장소(repository)를 변경하는 방법 (0) | 2022.12.12 |
우분투에서 TFTP 서버를 구축하는 방법 (0) | 2022.12.11 |
CentOS 7을 기준으로 RackTables를 설치하는 방법 (0) | 2022.12.11 |
mysqladmin 명령어 (0) | 2022.12.09 |