No voy a entrar a discutir si me parece mejor o peor que el sysVinit, simplemente quiero hacer una miniguia de adaptación a systemd.
Empecemos por el principio.
Listar servicios:
systemctl list-unit-files --type service
Ver si un servicio esta activo:
systemctl status name.service
ejemplo
[root@mi-centos7 ~]# systemctl status sshd.service
sshd.service - OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled)
Active: active (running) since lun 2014-10-27 11:02:29 CET; 1h 51min ago
Process: 1157 ExecStartPre=/usr/sbin/sshd-keygen (code=exited, status=0/SUCCESS)
Main PID: 1160 (sshd)
CGroup: /system.slice/sshd.service
1160 /usr/sbin/sshd -D
oct 27 11:02:29 mi-centos7 systemd[1]: Started OpenSSH server daemon.
oct 27 11:02:29 mi-centos7 sshd[1160]: Server listening on 0.0.0.0 port 22.
oct 27 11:02:29 mi-centos7 sshd[1160]: Server listening on :: port 22.
oct 27 11:08:40 mi-centos7 sshd[2206]: Accepted password for root from 10.0.2.2 port 59461 ssh2
Arrancar un servicio
systemctl start name.service
ejemplo
systemctl start sshd.service
Parar un servicio
systemctl stop name.service
ejemplo
systemctl stop sshd.service
Reiniciar un servicio
systemctl restart name.service
ejemplo
systemctl restart sshd.service
Habilitar un servicio
systemctl enable name.service
ejemplo
[root@mi-centos7 ~]# systemctl enable sshd.service
ln -s '/usr/lib/systemd/system/sshd.service' '/etc/systemd/system/multi-user.target.wants/sshd.service'
Deshabilitar un servicio
systemctl disable name.service
ejemplo
[root@mi-centos7 ~]# systemctl disable sshd.service
rm '/etc/systemd/system/multi-user.target.wants/sshd.service'
Y aquí una tabla con la equivalencia de service/chkconfig con el systemctl
service/chkconfig | systemctl | Description |
---|---|---|
service name start
| systemctl start name.service
| Starts a service. |
service name stop
| systemctl stop name.service
| Stops a service. |
service name restart
| systemctl restart name.service
| Restarts a service. |
service name condrestart
| systemctl try-restart name.service
| Restarts a service only if it is running. |
service name reload
| systemctl reload name.service
| Reloads configuration. |
service name status
| systemctl status name.service
systemctl is-active name.service
| Checks if a service is running. |
service --status-all
| systemctl list-units --type service --all
| Displays the status of all services. |
chkconfig name on
| systemctl enable name.service
| Enables a service. |
chkconfig name off
| systemctl disable name.service
| Disables a service. |
chkconfig --list name
| systemctl status name.service
systemctl is-enabled name.service
| Checks if a service is enabled. |
chkconfig --list
| systemctl list-unit-files --type service
| Lists all services and checks if they are enabled. |
Lo dejo como chuleta definitiva!!!
Espero que le sirva a alguien de ayuda.
Saludos y sed todo lo felices que podáis ser.
Quitos
Enlace con información extendida:
Enlace con información extendida:
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/System_Administrators_Guide/sect-Managing_Services_with_systemd-Services.html