Ubuntu, CentOS – Enable or Disable Service Autostart in Linux

Very often it is needed to enable or disable autostart of some services in Linux.

There are different init systems exist, but on Ubuntu and CentOS the most common are SysV, Upstart and systemd.

Depending on distribution, the behavior of a service during system’s boot in Linux can be configured with systemctl or chkconfig commands.

This tutorial shows how to enable or disable autostart of system services in the most popular Linux distributions – Ubuntu and CentOS.

Cool Tip: Want to become a DevOps engineer? Then you must know Git! This article helps to catch the Git basics really quickly! Read more →

Ubuntu-16.04

Supported releases: Ubuntu-15.04, 15.10, 16.04, 16.10.

systemd is a system and service manager for Linux operating systems.

It is now used by default in most Linux distributions and is fully supported in Ubuntu-15.04 and later releases.

It goes with systemctl command line tool, that among the other things, can enable and disable services at boot time.

Check if service is enabled or disabled on startup:

$ systemctl is-enabled SERVICE

Disable service autostart on Ubuntu-16.04:

$ sudo systemctl disable SERVICE

Enable service autostart on Ubuntu-16.04:

$ sudo systemctl enable SERVICE

Ubuntu-14.04

Supported releases: Ubuntu-9.10, 10.04, 10.10, 11.04, 11.10, 12.04, 12.10, 13.04, 13.10, 14.04, 14.10.

Check if service is enabled or disabled on startup:

$ initctl show-config SERVICE

Disable service autostart on Ubuntu-14.04:

$ echo manual | sudo tee /etc/init/SERVICE.override

Enable service autostart on Ubuntu-14.04:

$ sudo rm /etc/init/SERVICE.override

CentOS-7

systemd is a system and service manager for Linux operating systems,
that is widely becoming the new standard for Linux machines.

In CentOS-7, it replaces Upstart as the default init system.

systemd goes with systemctl command line utility that is the central management tool for systemd, that among the other things, can enable and disable services at boot time.

Cool Tip: Learn how to disable SELinux temporary or permanently! Read more →

Check if service is enabled or disabled on startup:

$ systemctl is-enabled SERVICE

Disable service autostart in CentOS-7:

$ systemctl disable SERVICE

Enable service autostart in CentOS-7:

$ systemctl enable SERVICE

CentOS-6

Cool Tip: Learn how to disable iptables on CentOS-6! Read more →

Check if service is enabled or disabled on startup:

$ chkconfig --list | grep SERVICE

Disable service autostart in CentOS-6:

$ chkconfig SERVICE off

Enable service autostart in CentOS-6:

$ chkconfig SERVICE on