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.
To auto-start a new service:
Find the name of the service script in the /etc/init.d/ directory (e.g., mysqld or httpd).
Add it to chkconfig:
sudo /sbin/chkconfig --add mysqld
Verify that it is registered in chkconfig:
sudo /sbin/chkconfig --list mysqld
Set it to auto-start:
sudo /sbin/chkconfig mysqld on
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