systemctl основные команды

Посмотреть статус, запустить, поставить в автозагрузку, убрать из автозагрузки, остановить, перечитать конфигурацию, рестартовать сервис

# systemctl status sshd
# systemctl start sshd
# systemctl enabled sshd
# systemctl disabled sshd
# systemctl stop sshd
# systemctl reload sshd
# systemctl restart sshd

Отобразить все активные юниты:

# systemctl list-units
  • UNIT: The systemd unit name
  • LOAD: Whether the unit’s configuration has been parsed by systemd. The configuration of loaded units is kept in memory.
  • ACTIVE: A summary state about whether the unit is active. This is usually a fairly basic way to tell if the unit has started successfully or not.
  • SUB: This is a lower-level state that indicates more detailed information about the unit. This often varies by unit type, state, and the actual method in which the unit runs.
  • DESCRIPTION: A short textual description of what the unit is/does.

Отобразить какие сервисы включены:

# systemctl list-unit-files --state=enabled
UNIT FILE            STATE
arpwatch.service     enabled
atop.service         enabled
auditd.service       enabled
autovt@.service      enabled
chronyd.service      enabled
...

–state={enabled,disabled,static}

# systemctl list-units --all --state=inactive

–state={inactive,active}

Отфильтровать также можно по типу

# systemctl list-units --type=service

–type={service,}

# systemctl list-unit-files

Отобразить Unit файл:

# systemctl cat sshd.service
# /usr/lib/systemd/system/sshd.service
[Unit]
Description=OpenSSH server daemon
Documentation=man:sshd(8) man:sshd_config(5)
After=network.target sshd-keygen.service
Wants=sshd-keygen.service

[Service]
Type=notify
EnvironmentFile=/etc/sysconfig/sshd
ExecStart=/usr/sbin/sshd -D $OPTIONS
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartSec=42s

[Install]
WantedBy=multi-user.target

Посмотреть с чем конфликтует:

# systemctl show sshd -p Conflicts
Conflicts=shutdown.target

 

image_pdfimage_print

Leave a Reply

Your email address will not be published. Required fields are marked *