systemctl
sistema / gestión energía
systemctl rebootsystemctl haltsystemctl poweroff- polkit es necesario para la gestión de energía:
systemctl suspendsystemctl hibernatesystemctl hybrid-sleep
servicios
status
global:
- listar todos los servicios activos en ejecución:
systemctl list-units --type service - listar todos los servicios activos/inactivos:
systemctl list-units --type service --all - listar servicios que han fallado:
systemclt --failed - listar servicios cargados:
systemctl -t service
individual:
- comprobar estado servicio:
systemctl status nombre.service - comprobar si está habilitado:
systemctl is-enabled nombre.service - comprobar si está activado:
systemctl is-active nombre.service - comprobar status en otra máquina:
systemctl status sshd -H user@maquina(pide contraseña de user)
activar/desactivar
- habilitar un servicio:
systemctl enable nombre.service - deshabilitar un servicio:
systemctl disable nombre.servicio - Inciciar, parar o reiniciar un servicio:
systemctl {start|stop|restart} nombre.service - Reiniciar servicio (solo si ya lo está):
systemctl try-restart nombre.service - recargar configuración:
systemctl reload nombre.service
manejo servicios
- matar un servicio (SIGTERM por defecto):
systemctl kill nombre.servicio - matar un servicio con señal determinada:
systemctl kill -s <SEÑAL> nombre.service
unidades
- cambiar a la unidad de destino predeterminada:
systemctl default - iniciar la unidad especificada, detener el resto:
systemctl isolate nombre.target
enmascarar/desemascarar
cuando se enmascara un servicio, se deshabilita y se anula inicio manual o automático
systemctl mask nombre.servicesystemctl unmask nombre.service
otros comandos
- análisis tiempo inicio:
systemd-analyze - arbol de procesos arrancado por cada servicio:
systemd-cgls
comandos programáticos
systemctl is-active –quiet <SERVICIO>- retorna en
$?el estado… 0 para activo, no 0 para el resto