How to enable and disable services in CentOS 8

From Computernewb Wiki
Jump to navigation Jump to search

< Configure the network | Update the system >

You can view all the active services on the system with systemctl.

[root@localhost ~]# systemctl -t service
UNIT                            LOAD   ACTIVE SUB     DESCRIPTION
atd.service                     loaded active running Job spooling tools
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
.....
.....
[email protected]      loaded active exited  /run/user/0 mount wrapper
[email protected]                  loaded active running User Manager for UID 0
vdo.service                     loaded active exited  VDO volume services

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.

45 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'

You can list all of the services like this:

[root@localhost ~]# systemctl list-unit-files -t service
UNIT FILE                                   STATE
arp-ethers.service                          disabled
atd.service                                 enabled
auditd.service                              enabled
[email protected]                             enabled
blk-availability.service                    disabled
.....
.....
[email protected]                   static
[email protected]                               static
vdo.service                                 enabled

181 unit files listed.

You can disable a service like this. In this example we stop firewalld.

[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld

To enable it again, we just use this:

[root@localhost ~]# systemctl start firewalld
[root@localhost ~]# systemctl enable firewalld

To check a status of a service do this:

[root@localhost ~]# systemctl status firewalld
*  firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor pr
   Active: active (running) since Tue 2019-10-29 22:14:39 EDT; 44min ago
     Docs: man:firewalld(1)
 Main PID: 705 (firewalld)
    Tasks: 2 (limit: 4915)
   CGroup: /system.slice/firewalld.service
           └─705 /usr/libexec/platform-python -s /usr/sbin/firewalld --nofork

< Configure the network | Update the system >