How to Enable or Disable services on boot with chkconfig | systemctl – RHEL-6/7/8


How to Enable or Disable services on boot with chkconfig | systemctl – RHEL-6/7/8: Chkconfig and systemctl are the command line tool provided with RHEL-6 (Chkconfig ), RHEL-7 and RHEL-8 (systemctl) correspondingly to manage started services in different runlevels of the system. Using chkconfig and systemctl we can Enable or Disable services on boot. Previous versions of Red Hat Enterprise Linux, which were used init scripts located in the /etc/rc.d/init.d/ directory to start, stop, restart, enable, or disable system services.


In this topic we will discuss how to managing system services and chkconfig vs systemctl. On RHEL-6 (Chkconfig ), RHEL-7 and RHEL-8 (systemctl) as service does not support chkconfig. 

Enable or Disable services on boot with chkconfig | systemctl
Chkconfig command: RHEL-6
Note: httpd service taken as

Step-1: List the current runlevels where the services will be starting
# chkconfig --list httpd
httpd                     0:off      1:off      2:off      3:off      4:off      5:off      6:off

Step-2: Enabling the service on runlevel 2,3,4 and 5 without specifying any runlevel
# chkconfig httpd on
httpd                     0:off      1:off      2:on       3:on       4:on       5:on       6:off

Step-3: List the current runlevels where the services will be starting
# chkconfig --list httpd
httpd                     0:off      1:off      2:on       3:on       4:on       5:on       6:off

Step-4: Disabling the service for all runlevels
# chkconfig httpd off
httpd                     0:off      1:off      2:off      3:off      4:off      5:off      6:off

Step-5: Enabling the service only on runlevel 3 and 5
# chkconfig --level 35 httpd on

Step-6: List the current runlevels where the services will be starting
# chkconfig --list httpd
httpd                     0:off      1:off      2:off      3:on       4:off      5:on       6:off

Systemctl command: RHEL7/8
Note: firewalld service taken as example

Step-1: Check the status of the service
# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: inactive (dead)
   Docs: man:firewalld(1)

Step-2: Enable the service
# systemctl enable firewalld

Step-3: Start the service
# systemctl start firewalld

Step-4: Check the status of the service
# systemctl is-enabled firewalld
enabled

# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
     Loaded:   loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
      Active:     active (running) since Wed 2019-09-25 13:28:59 IST; 2s ago
        Docs:     man:firewalld(1)
 Main PID:    36859 (firewalld)
   CGroup:    /system.slice/firewalld.service ─36859 /usr/bin/python2 -Es /usr/sbin/firewalld --nofork --nopid

Sep 25 13:28:59 ndc110-testc-25 systemd[1]: Starting firewalld - dynamic firewall daemon...
Sep 25 13:28:59 ndc110-testc-25 systemd[1]: Started firewalld - dynamic firewall daemon.

Step-5: Displays the status of all services
# systemctl list-units --type service –all

Step-6: Lists all services and checks if they are enabled
# systemctl list-units --type service

Comments

Post a Comment

Popular posts from this blog

How to install glibc 2.14 on RHEL 6/ RHEL 7/ CentOS 7

Export and Import users/groups and OU in AD Server 2008 using LDIFDE command.

How to Set Up and Configure latest yum repository on CentOS