Linux: Configurando servicos utilizando o systemctl
O systemctl é a ferramenta para gerenciar serviços no Fedora.
Listando os serviços
para listar serviços utilize o systemctl com as seguintes opções:
# systemctl -t service UNIT LOAD ACTIVE SUB DESCRIPTION abrt-ccpp.service loaded active exited Install ABRT coredump hook abrt-oops.service loaded active running ABRT kernel log watcher abrt-xorg.service loaded active running ABRT Xorg log watcher abrtd.service loaded active running ABRT Automated Bug Reporting Tool accounts-daemon.service loaded active running Accounts Service ... systemd-vconsole-setup.service loaded active exited Setup Virtual Console udisks2.service loaded active running Disk Manager upower.service loaded active running Daemon for power management wpa_supplicant.service loaded active running WPA Supplicant daemon LOAD = Reflects whether the unit definition was properly loaded. ACTIVE = The high-level unit activation state, i.e. generalization of SUB. SUB = The low-level unit activation state, values depend on unit type. 60 loaded units listed. Pass --all to see loaded but inactive units, too. To show all installed unit files use 'systemctl list-unit-files'.
Verificando o status de um serviço
Para verificar um serviço no sistema digite
# systemctl status httpd.service httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled) Active: active (running) since Tue 2013-08-06 10:35:56 BRT; 44s ago Process: 24662 ExecStop=/usr/sbin/httpd $OPTIONS -k graceful-stop (code=exited, status=0/SUCCESS) Main PID: 24679 (httpd) Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec" CGroup: name=systemd:/system/httpd.service ├─24679 /usr/sbin/httpd -DFOREGROUND ├─24680 /usr/sbin/httpd -DFOREGROUND ├─24681 /usr/sbin/httpd -DFOREGROUND ├─24682 /usr/sbin/httpd -DFOREGROUND ├─24683 /usr/sbin/httpd -DFOREGROUND └─24684 /usr/sbin/httpd -DFOREGROUND
Iniciando um serviço
Para iniciar um serviço no sistema digite
# systemctl start httpd.service
Parar um serviço
Para arar um serviço no sistema digite
# systemctl stop httpd.service
Verificar se um serviço esta ativo
Para verificar se um serviço no sistema digite
# systemctl is-enabled httpd.service enabled
Para desativar um serviço esta ativo
Para desativar um serviço no sistema digite
# systemctl disable httpd.service rm '/etc/systemd/system/multi-user.target.wants/httpd.service'
Para ativar um serviço esta ativo
Para ativar um serviço no sistema digite
# systemctl enable httpd.service ln -s '/usr/lib/systemd/system/httpd.service' '/etc/systemd/system/multi-user.target.wants/httpd.service'