[4] Włączanie i wyłączanie usług

19 maja 2020 Wyłączono przez Adam [zicherka] Nogły

[1] Wyświetlenie listy usług, które obecnie są aktywne.

[root@lsr01vm ~]# systemctl -t service
  UNIT                                              LOAD   ACTIVE SUB     DESCRIPTION
  auditd.service                                    loaded active running Security Auditing Service
  chronyd.service                                   loaded active running NTP client/server
  crond.service                                     loaded active running Command Scheduler
  dbus.service                                      loaded active running D-Bus System Message Bus
  dracut-shutdown.service                           loaded active exited  Restore /run/initramfs on>
  firewalld.service                                 loaded active running firewalld - dynamic firew>
  getty@tty1.service                                loaded active running Getty on tty1
  import-state.service                              loaded active exited  Import network configurat>
● kdump.service                                     loaded failed failed  Crash recovery kernel arm>
  kmod-static-nodes.service                         loaded active exited  Create list of required s>
  lvm2-monitor.service                              loaded active exited  Monitoring of LVM2 mirror>
  lvm2-pvscan@8:2.service                           loaded active exited  LVM event activation on d>
  NetworkManager-wait-online.service                loaded active exited  Network Manager Wait Onli>
  NetworkManager.service                            loaded active running Network Manager
  nis-domainname.service                            loaded active exited  Read and set NIS domainna>
  polkit.service                                    loaded active running Authorization Manager
  rngd.service                                      loaded active running Hardware RNG Entropy Gath>
  rsyslog.service                                   loaded active running System Logging Service
  sshd.service                                      loaded active running OpenSSH server daemon
  sssd.service                                      loaded active running System Security Services >
  systemd-fsck@dev-disk-by\x2duuid-a5ee781e\x2d61ec\x2d48bf\x2d82f0\x2d9f21d334ff08.service loaded >
  systemd-journal-flush.service                     loaded active exited  Flush Journal to Persiste>
  systemd-journald.service                          loaded active running Journal Service
  systemd-logind.service                            loaded active running Login Service
  systemd-random-seed.service                       loaded active exited  Load/Save Random Seed
  systemd-remount-fs.service                        loaded active exited  Remount Root and Kernel F>
  systemd-sysctl.service                            loaded active exited  Apply Kernel Variables
  systemd-tmpfiles-setup-dev.service                loaded active exited  Create Static Device Node>
  systemd-tmpfiles-setup.service                    loaded active exited  Create Volatile Files and>
  systemd-udev-trigger.service                      loaded active exited  udev Coldplug all Devices
  systemd-udevd.service                             loaded active running udev Kernel Device Manager
  systemd-update-utmp.service                       loaded active exited  Update UTMP about System >
  systemd-user-sessions.service                     loaded active exited  Permit User Sessions
  tuned.service                                     loaded active running Dynamic System Tuning Dae>
  user-runtime-dir@0.service                        loaded active exited  /run/user/0 mount wrapper
  user@0.service                                    loaded active running User Manager for UID 0

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.

36 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.
[2] Wyświetlenie WSZYSTKICH usług.
[root@lsr01vm ~]# systemctl list-unit-files -t service
UNIT FILE                                  STATE
auditd.service                             enabled
autovt@.service                            enabled
blk-availability.service                   disabled
chrony-dnssrv@.service                     static
chrony-wait.service                        disabled
chronyd.service                            enabled
console-getty.service                      disabled
container-getty@.service                   static
cpupower.service                           disabled
crond.service                              enabled
dbus-org.fedoraproject.FirewallD1.service  enabled
dbus-org.freedesktop.hostname1.service     static
dbus-org.freedesktop.locale1.service       static
dbus-org.freedesktop.login1.service        static
dbus-org.freedesktop.nm-dispatcher.service enabled
dbus-org.freedesktop.portable1.service     static
dbus-org.freedesktop.timedate1.service     enabled
dbus.service                               static
debug-shell.service                        disabled
dm-event.service                           static
dnf-makecache.service                      static
dracut-cmdline.service                     static
dracut-initqueue.service                   static
dracut-mount.service                       static
dracut-pre-mount.service                   static
dracut-pre-pivot.service                   static
dracut-pre-trigger.service                 static
dracut-pre-udev.service                    static
dracut-shutdown.service                    static
ebtables.service                           disabled
emergency.service                          static
firewalld.service                          enabled
fstrim.service                             static
getty@.service                             enabled
grub-boot-indeterminate.service            static
halt-local.service                         static
import-state.service                       enabled
initrd-cleanup.service                     static
initrd-parse-etc.service                   static
initrd-switch-root.service                 static
initrd-udevadm-cleanup-db.service          static
iprdump.service                            disabled
iprinit.service                            disabled
iprupdate.service                          disabled
irqbalance.service                         enabled
kdump.service                              enabled
kmod-static-nodes.service                  static
ldconfig.service                           static
loadmodules.service                        enabled
lvm2-lvmpolld.service                      static
lvm2-monitor.service                       enabled
lvm2-pvscan@.service                       static
man-db-cache-update.service                static
messagebus.service                         static
microcode.service                          enabled
NetworkManager-dispatcher.service          enabled
NetworkManager-wait-online.service         enabled
NetworkManager.service                     enabled
nftables.service                           disabled
nis-domainname.service                     enabled
plymouth-halt.service                      static
plymouth-kexec.service                     static
plymouth-poweroff.service                  static
plymouth-quit-wait.service                 static
plymouth-quit.service                      static
plymouth-read-write.service                static
plymouth-reboot.service                    static
plymouth-start.service                     static
plymouth-switch-root.service               static
polkit.service                             static
quotaon.service                            static
rc-local.service                           static
rdisc.service                              disabled
rescue.service                             static
rngd.service                               enabled
rsyslog.service                            enabled
selinux-autorelabel-mark.service           enabled
selinux-autorelabel.service                static
serial-getty@.service                      disabled
sshd-keygen@.service                       disabled
sshd.service                               enabled
sshd@.service                              static
sssd-autofs.service                        indirect
sssd-kcm.service                           indirect
sssd-nss.service                           indirect
sssd-pac.service                           indirect
sssd-pam.service                           indirect
sssd-ssh.service                           indirect
sssd-sudo.service                          indirect
sssd.service                               enabled
syslog.service                             enabled
system-update-cleanup.service              static
systemd-ask-password-console.service       static
systemd-ask-password-plymouth.service      static
systemd-ask-password-wall.service          static
systemd-backlight@.service                 static
systemd-binfmt.service                     static
systemd-coredump@.service                  static
systemd-exit.service                       static
systemd-firstboot.service                  static
systemd-fsck-root.service                  static
systemd-fsck@.service                      static
systemd-halt.service                       static
systemd-hibernate-resume@.service          static
systemd-hibernate.service                  static
systemd-hostnamed.service                  static
systemd-hwdb-update.service                static
systemd-hybrid-sleep.service               static
systemd-initctl.service                    static
systemd-journal-catalog-update.service     static
systemd-journal-flush.service              static
systemd-journald.service                   static
systemd-kexec.service                      static
systemd-localed.service                    static
systemd-logind.service                     static
systemd-machine-id-commit.service          static
systemd-modules-load.service               static
systemd-portabled.service                  static
systemd-poweroff.service                   static
systemd-quotacheck.service                 static
systemd-random-seed.service                static
systemd-reboot.service                     static
systemd-remount-fs.service                 static
systemd-resolved.service                   disabled
systemd-rfkill.service                     static
systemd-suspend-then-hibernate.service     static
systemd-suspend.service                    static
systemd-sysctl.service                     static
systemd-sysusers.service                   static
systemd-timedated.service                  masked
systemd-tmpfiles-clean.service             static
systemd-tmpfiles-setup-dev.service         static
systemd-tmpfiles-setup.service             static
systemd-udev-settle.service                static
systemd-udev-trigger.service               static
systemd-udevd.service                      static
systemd-update-done.service                static
systemd-update-utmp-runlevel.service       static
systemd-update-utmp.service                static
systemd-user-sessions.service              static
systemd-vconsole-setup.service             static
systemd-volatile-root.service              static
tcsd.service                               disabled
teamd@.service                             static
timedatex.service                          enabled
tuned.service                              enabled
unbound-anchor.service                     static
user-runtime-dir@.service                  static
user@.service                              static

149 unit files listed.
[3] Zatrzymanie i wyłączenie usługi, której nie potrzebujesz. Rozruch i włączenie podczas startu systemu usługi (firewalld jest tylko przykładową usługą 😉 ).
[root@lsr01vm ~]# systemctl stop firewalld # zatrzymanie usługi
[root@lsr01vm ~]# systemctl disable firewalld # wyłączenie usługi
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@lsr01vm ~]# systemctl start firewalld # rozruch usługi
[root@lsr01vm ~]# systemctl enable firewalld # włączenie podczas startu usługi
Created symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service → /usr/lib/systemd/system/firewalld.service.
Created symlink /etc/systemd/system/multi-user.target.wants/firewalld.service → /usr/lib/systemd/system/firewalld.service.