pmhaynes

Just another WordPress site

  • Buy Adspace

How to enable or disable services in Debian / Ubuntu

Posted by Paul on October 8, 2014
Posted in: Linux.

Source

 

To Enable and disable services across runlevels in Debian, Ubuntu, and other Debian based Linux distributions we use a script called update-rc.d. 

How to enable a service


As an example, to enable Apache web server in Debian, do the following –

# update-rc.d apache2 defaults


… this will enable the Apache web server to start in the default run levels of 2,3,4 and 5. Of course, you can do it explicitly by giving the run levels instead of the defaults keyword as follows:

# update-rc.d apache2 start 20 2 3 4 5 . stop 80 0 1 6 .


The above command modifies the sym-links in the respective /etc/rcX.d directories to start or stop the service in the destined runlevels. Here X stands for a value of 0 to 6 depending on the runlevel. One thing to note here is the dot (.) which is used to terminate the set which is important. Also 20 and 80 are the sequence codes which decides in what order of precedence the scripts in the /etc/init.d/ directory should be started or stopped.

To enable the service only in runlevel 5, you do this instead –

# update-rc.d apache2  start 20 5 . stop 80 0 1 2 3 4 6 .

 

How to disable a service


To disable the service in all the run levels, you execute the command:

# update-rc.d -f apache2 remove


Here -f option which stands for force is mandatory.

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook

Like this:

Like Loading...

Posts navigation

← Useful IPtables commands
How to change netbios name to be FQDN →
  • Advert

  • Recent Posts

    • MS Office 2010 working links on Microsoft URL
    • Change your LAN from public to Private Profile with Powershell on Windows 10
    • How to change WordPress upload size limit
    • Routing network traffic between 2 subnets using a Raspberry Pi
    • OpenVPN setup
  • Recent Comments

    • Archives

      • March 2023 (2)
      • June 2021 (1)
      • February 2019 (1)
      • December 2018 (1)
      • March 2018 (2)
      • April 2015 (2)
      • January 2015 (1)
      • October 2014 (1)
      • June 2014 (1)
      • May 2014 (6)
      • April 2014 (2)
      • March 2014 (1)
      • January 2014 (1)
      • December 2013 (1)
      • November 2013 (6)
    • Categories

      • Linux
      • Uncategorized
      • Windows
      • Wordpress
    • Meta

      • Log in
      • Entries feed
      • Comments feed
      • WordPress.org
    Proudly powered by WordPress Theme: Parament by Automattic.
    %d