How to auto-start services on boot in CentOS / Red Hat / Oracle Linux?

To auto-start services in CentOS, Red Hat, or Oracle Linux, you can use the built-in chkconfig utility. It is located in the /sbin directory. If you are a regular user (non-root), /sbin may not be in your PATH, so you may have to use the full path to run the chkconfig utility.

centos

To auto-start a new service:

  1. Find the name of the service script in the /etc/init.d/ directory (e.g., mysqld or httpd).
  2. Add it to chkconfig:
    sudo /sbin/chkconfig --add mysqld
  3. Verify that it is registered in chkconfig:
    sudo /sbin/chkconfig --list mysqld
  4. Set it to auto-start:
    sudo /sbin/chkconfig mysqld on
  5. To prevent a service from auto-starting on boot:
    sudo /sbin/chkconfig mysqld off

Modern CentOS / RHEL / Oracle Linux 7, 8, and 9+ (systemd):

Modern Enterprise Linux releases use systemd instead of SysV chkconfig:

# Enable a service to start at boot (and start it immediately)
sudo systemctl enable --now httpd

# Enable or disable boot auto-start
sudo systemctl enable mysqld
sudo systemctl disable mysqld

# Check current boot status
sudo systemctl is-enabled mysqld

Comments are Disabled