Skip to content

Instantly share code, notes, and snippets.

@jesherdevsk8
Created October 11, 2024 14:10
Show Gist options
  • Save jesherdevsk8/89f87dbf4f10f32be45de37ee51a6bc9 to your computer and use it in GitHub Desktop.
Save jesherdevsk8/89f87dbf4f10f32be45de37ee51a6bc9 to your computer and use it in GitHub Desktop.

Comandos básicos do systemctl:

  • Verificar status de serviços:

    systemctl status nginx
    systemctl status apache2.service
    systemctl status cups
    systemctl status bluetooth.service
  • Iniciar, parar e reiniciar serviços:

    sudo systemctl start apache2.service
    sudo systemctl stop apache2.service
    sudo systemctl restart apache2.service
  • Ativar e desativar serviços no boot:

    sudo systemctl enable apache2.service --now  # Ativa e inicia o serviço
    sudo systemctl disable apache2.service --now  # Desativa e para o serviço
  • Verificar se um serviço está habilitado no boot:

    sudo systemctl is-enabled apache2.service

Serviços múltiplos (cups, bluetooth, etc.):

  • Status de múltiplos serviços:

    sudo systemctl status cups-browsed.service accounts-daemon.service cups.service cups.socket
  • Habilitar e desabilitar múltiplos serviços:

    sudo systemctl enable cups-browsed.service cups.socket cups.service
    sudo systemctl disable cups-browsed.service cups.socket cups.service --now
  • Verificar se múltiplos serviços estão habilitados:

    systemctl is-enabled cups-browsed.service cups.socket cups.service

Análise e diagnósticos:

  • Analisar tempos de inicialização de serviços:

    systemd-analyze
    systemd-analyze blame
  • Monitorar uso de cgroups:

    systemd-cgtop
    sudo systemd-cgtop -m

Outros comandos úteis:

  • Visualizar o conteúdo de unidades de serviço:

    systemctl cat docker.socket
    systemctl cat cups.socket
    systemctl cat bluetooth
    
    # SysVinit Service
    cat /etc/init.d/bluetooth
  • Listar unidades e verificações adicionais:

    ls /etc/systemd/system
    ls -l /etc/systemd/system/bluetooth.target.wants
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment