Adding a service to autostart
systemd (AlmaLinux, Rocky Linux, CentOS 7 and later, Ubuntu 16.04 and later)
Enable the httpd service at boot:
systemctl enable httpd.service
Disable it:
systemctl disable httpd.service
Check the status:
systemctl status httpd.service
Enable and start it in one command:
systemctl enable --now httpd.service
List everything that starts automatically:
systemctl list-unit-files --state=enabled
SysV init (CentOS 6 and earlier)
Older systems use chkconfig. The syntax is:
chkconfig --list service_name
chkconfig --add service_name
chkconfig --del service_name
chkconfig [--level levels] service_name <on|off|reset>
List the services that load at boot:
chkconfig --list | grep on
Check whether httpd is enabled:
chkconfig --list httpd
Enable it at run level 3:
chkconfig --level 3 httpd on
Enable it at every level:
chkconfig httpd on
RedHat-derived distributions such as CentOS and Fedora use SysV init with six run levels:
0 — Halt
1 — Single-user text mode
2 — Not used (user-definable)
3 — Full multi-user text mode
4 — Not used (user-definable)
5 — Full multi-user graphical mode
Enabling services at run level 3 (multi-user text mode) is recommended.