systemctl
Processos e sistema
Uso
systemctl <verb> <unit>Inicia, para e inspeciona servicos do systemd; `enable` so define o comportamento no boot, entao use `enable --now` para iniciar tambem, e rode `daemon-reload` depois de editar um unit.
Opções comuns
| Opção | Significado |
|---|---|
| status <unit> | Whether it is running, its PID, and the last log lines. |
| start / stop / restart | Act on the service now, without changing boot behaviour. |
| reload | Re-read the config without dropping connections, if the service supports it. |
| enable --now <unit> | Start it now and also start it at every boot. |
| daemon-reload | Required after you edit a .service file, before restarting it. |
| list-units --failed | Everything that failed to start. |
| --user | Act on your own user units instead of the system ones. |
Exemplos
sudo systemctl restart nginxRestart the web server.
systemctl status sshd --no-pagerPrint the state and recent log lines without opening a pager.
sudo systemctl enable --now dockerStart Docker and make it come back after a reboot.
O que está rodando e o que está comendo a máquina. Identificar vem antes de matar.
Como ler
- Os colchetes [ ] marcam uma parte que você pode omitir.
- As reticências … indicam que você pode listar vários.
- As opções diferenciam maiúsculas: em alguns comandos -r e -R fazem coisas diferentes.
Perguntas
Q. O que systemctl faz?
Inicia, para e inspeciona servicos do systemd; `enable` so define o comportamento no boot, entao use `enable --now` para iniciar tambem, e rode `daemon-reload` depois de editar um unit.
Q. Como se digita?
systemctl <verb> <unit> — os colchetes marcam o que você pode omitir.
Q. Quantas opções vale a pena saber?
Aqui estão 7; a lista completa está em man systemctl. Este comando fica em Processos e sistema.
Comandos relacionados
página man: man systemctl