From Fedora Project Wiki

< SysVinit to Systemd Cheatsheet

Revision as of 11:16, 22 November 2011 by Gomix (talk | contribs) (Progreso en la traducción/Some progress translating)

Este documento es para ayudar a los administradores de sistema que necesitan entender cuáles son los comandos en systemd que remplazan la forma de trabajo antigua de sysvinit. Si desea información general acerca de systemd refiérase a systemd.

Note que los comandos 'service' y 'chkconfig' continuarán funcionando igual pero en el mundo systemd. Esta guía es acerca de cómo usar los comandos remplazos nativos systemctl.

Servicios

Comando sysvinit Comando systemd Notas
service frobozz start systemctl start frobozz.service Utilizado para arrancar el servicio (no resiste reinicio)
service frobozz stop systemctl stop frobozz.service Utilizado para detener el servicio (no resiste a reinicio)
service frobozz restart systemctl restart frobozz.service Utilizado para detener y arrancar el servicio.
service frobozz reload systemctl reload frobozz.service Cuando se soporta, recarga el archivo de configuración sin interrumpir las operaciones pendientes.
service frobozz condrestart systemctl condrestart frobozz.service Rearranca el servicio si ya está ejecutándose.
service frobozz status systemctl status frobozz.service Indica si el servicio está en ejecución o no.
ls /etc/rc.d/init.d/ ls /lib/systemd/system/*.service /etc/systemd/system/*.service
systemctl list-units --all
Utilizado para listar los servicios que pueden ser iniciados o detenidos
Utilizado para listar todos los servicios y otros units
chkconfig frobozz on systemctl enable frobozz.service Pone el servicio en "on", para que se inicie cuando se inicie la máquina u otro disparador como cambio de nivel de ejecución.
chkconfig frobozz off systemctl disable frobozz.service Pone el servicio en "off" para que al iniciar el sistema, no se inicie el servicio o se detenga por ejemplo al momento de cambio de nivel de ejecución.
chkconfig frobozz systemctl is-enabled frobozz.service Utilizado para verificar si un servicio está configurado para ser iniciado en el entorno actual.
chkconfig frobozz --list ls /etc/systemd/system/*.wants/frobozz.service Utilizado para listar qué niveles de ejecución el servicio está en "on" o "off".
chkconfig frobozz --add systemctl daemon-reload Utilizado para cuando se desea crear un nuevo archivo de servicio o modificar su configuración.

Note que todas las líneas /sbin/service y /sbin/chkconfig listadas arriba continúan funcionando en systemd y serán traducidos a comandos nativos systemd en la medida de que sea necesario. La única excepción es chkconfig --list.

Warning.png
Comandos adicionales
In SysVinit, services can define arbitrary commands. Examples would be service iptables panic, or service httpd graceful. Native systemd services do not have this ability.

Any service that defines an additional command in this way would need to define some other, service-specific, way to accomplish this task when writing a native systemd service definition.

Check the package-specific release notes for any services that may have done this.

Runlevels/targets

Systemd has a concept of targets which serve a similar purpose as runlevels but act a little different. Each target is named instead of numbered and is intended to serve a specific purpose. Some targets are implemented by inheriting all of the services of another target and adding additional services to it. There are systemd targets that mimic the common sysvinit runlevels so you can still switch targets using the familiar telinit RUNLEVEL command. The runlevels that are assigned a specific purpose on vanilla Fedora installs; 0, 1, 3, 5, and 6; have a 1:1 mapping with a specific systemd target. Unfortunately, there's no good way to do the same for the user-defined runlevels like 2 and 4. If you make use of those it is suggested that you make a new named systemd target as /etc/systemd/system/$YOURTARGET that takes one of the existing runlevels as a base (you can look at /lib/systemd/system/graphical.target as an example), make a directory /etc/systemd/system/$YOURTARGET.wants, and then symlink the additional services that you want to enable into that directory. (The service unit files that you symlink live in /lib/systemd/system).

sysvinit Runlevel systemd Target Notes
0 runlevel0.target, poweroff.target Halt the system.
1, s, single runlevel1.target, rescue.target Single user mode.
2, 4 runlevel2.target, runlevel4.target, multi-user.target User-defined/Site-specific runlevels. By default, identical to 3.
3 runlevel3.target, multi-user.target Multi-user, non-graphical. Users can usually login via multiple consoles or via the network.
5 runlevel5.target, graphical.target Multi-user, graphical. Usually has all the services of runlevel 3 plus a graphical login.
6 runlevel6.target, reboot.target Reboot
emergency emergency.target Emergency shell

Changing runlevels:

sysvinit Command systemd Command Notes
telinit 3 systemctl isolate multi-user.target (OR systemctl isolate runlevel3.target OR telinit 3) Change to multi-user run level.
sed s/^id:.*:initdefault:/id:3:initdefault:/ ln -sf /lib/systemd/system/multi-user.target /etc/systemd/system/default.target Set to use multi-user runlevel on next reboot.