InfoHeap
Tech
Navigation
  • Home
  • Tutorials
    • CSS tutorials & examples
    • CSS properties
    • Javascript cookbook
    • Linux/Unix Command Line
    • Mac
    • PHP
      • PHP functions online
      • PHP regex
    • WordPress
  • Online Tools
    • Text utilities
    • Online Lint Tools
search

Ubuntu tutorials

  • How to add a user on Linux with sudo access
  • How to check if a user has password on Linux
  • How to install ViewVC for svn repository on Ubuntu Linux
  • How to setup ssl (https) for your site on Ubuntu Linux
  • Install rabbitmq on Ubuntu Linux
  • LXC (Linux Containers) - quick start tutorial on Ubuntu
  • Linux - command to check swap size
  • Linux - how to add a user using useradd
  • Linux - how to create a large file like 1GB
  • Linux - how to create swap partition
  • Linux - how to remove user from a group
  • Linux - number of cpus (lscpu)
  • Linux du - find disk usage of directories or files
  • NFS client and server handy commands
  • Setup svn repository on AWS Ubuntu with apache auth
  • Ubuntu - check if a service is upstart based
  • Ubuntu - dpkg and apt-get beginner tutorial
  • Ubuntu - find file to package
  • Ubuntu - find where will a package be installed from
  • Ubuntu - how to auto start services on boot using update-rc.d (sysv init)
  • Ubuntu - how to find boot autostart status of a service
  • Ubuntu - reload iptables rules during boot
  • Use x2go to access remote Ubuntu Linux
 
  • Home
  • > Tutorials
  • > Ubuntu Linux

Ubuntu – how to auto start services on boot using update-rc.d (sysv init)

on Feb 13, 2016

Utility update-rc.d is part of sysv init (package sysv-rc) on Ubuntu Linux. It can be used to manage services at boot time. It can be used to add or remove a service from auto start list. Note that this is only relevant for non upstart based services. Some upstart and sysv init based services at the time of writing this tutorial are:

  1. sysv init based: apache2, memcached, jenkin, etc. This tutorial is only relevant for sysv init based services.
  2. upstart based: mysql, docker, etc.

What does update-rc.d do?

update-rc.d creates symlinks in /etc/rc*.d/ for various run levels pointing to /etc/init.d/service_script (e.g. /etc/init.d/apache2) when a service is enabled to auto start on boot.

Add a service to auto start at boot time in dry-run mode

We’ll use nginx for this example. Also note that -n is for dryrun.

## dry-run
$ sudo update-rc.d -n nginx defaults
 Adding system startup for /etc/init.d/nginx ...
   /etc/rc0.d/K20nginx -> ../init.d/nginx
   /etc/rc1.d/K20nginx -> ../init.d/nginx
   /etc/rc6.d/K20nginx -> ../init.d/nginx
   /etc/rc2.d/S20nginx -> ../init.d/nginx
   /etc/rc3.d/S20nginx -> ../init.d/nginx
   /etc/rc4.d/S20nginx -> ../init.d/nginx
   /etc/rc5.d/S20nginx -> ../init.d/nginx

Add a service to auto start at boot time in real-run mode

We’ll use nginx for this example. Also note that we are not using -n here.

## real-run
$ sudo update-rc.d nginx defaults
 Adding system startup for /etc/init.d/nginx ...
   /etc/rc0.d/K20nginx -> ../init.d/nginx
   /etc/rc1.d/K20nginx -> ../init.d/nginx
   /etc/rc6.d/K20nginx -> ../init.d/nginx
   /etc/rc2.d/S20nginx -> ../init.d/nginx
   /etc/rc3.d/S20nginx -> ../init.d/nginx
   /etc/rc4.d/S20nginx -> ../init.d/nginx
   /etc/rc5.d/S20nginx -> ../init.d/nginx

See if a service will start at boot time

To so if service nginx will start at boot time we can use two approaches.

  1. By adding service to auto start in dry-run mode (-n). This will work if service has been added by update-rc.d.

    ## dry-run
    $ sudo update-rc.d -n  nginx defaults
     System start/stop links for /etc/init.d/nginx already exist.
    

    If we get “already exist” message, that means service will autostart at boot time.

  2. By viewing files in /etc/rc*.d/

    $ ls /etc/rc*.d/*nginx*
    /etc/rc0.d/K20nginx  /etc/rc1.d/K20nginx  /etc/rc2.d/S20nginx  /etc/rc3.d/S20nginx  /etc/rc4.d/S20nginx  /etc/rc5.d/S20nginx  /etc/rc6.d/K20nginx
    

    Presence of these script in /etc/rc*.d/* implies that nginx will autostart at reboot.

Remove a service from auto start at boot time in dry-run mode

We’ll use nginx for this example. Also note that -n is for dryrun. When service auto start is in enabled state, you will get the following outcome.

## dry-run
$ sudo update-rc.d -n -f nginx remove
 Removing any system startup links for /etc/init.d/nginx ...
   /etc/rc0.d/K20nginx
   /etc/rc1.d/K20nginx
   /etc/rc2.d/S20nginx
   /etc/rc3.d/S20nginx
   /etc/rc4.d/S20nginx
   /etc/rc5.d/S20nginx
   /etc/rc6.d/K20nginx

Remove a service from auto start at boot time in real-run mode

We’ll use nginx for this example. Also note that -n is not present here. When service auto start is setup, you will get the following outcome.

## real-run
$ sudo update-rc.d -f nginx remove
 Removing any system startup links for /etc/init.d/nginx ...
   /etc/rc0.d/K20nginx
   /etc/rc1.d/K20nginx
   /etc/rc2.d/S20nginx
   /etc/rc3.d/S20nginx
   /etc/rc4.d/S20nginx
   /etc/rc5.d/S20nginx
   /etc/rc6.d/K20nginx

Suggested posts:

  1. How to find docker host ip on Mac
  2. Centos/RHEL – find package for a file
  3. WordPress – exclude specific posts from archive pages
  4. jQuery toggleClass() examples
  5. Ubuntu – how to find boot autostart status of a service
  6. LXC (Linux Containers) – quick start tutorial on Ubuntu
  7. Chrome extension tutorial – access active page dom
  8. Java – Arrays.sort custom Comparator example
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged Tutorials, Ubuntu Linux
  • Browse content
  • Article Topics
  • Article archives
  • Contact Us
Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | Company results | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | Kubernetes | Linux | Linux/Unix Command Line | Mac | Mac Command Line | Mysql | Networking | Node.js | Online Tools | PHP | PHP cookbook | PHP Regex | Python | Python array | Python cookbook | SEO | Site Performance | SSH | Ubuntu Linux | Web Development | Webmaster | Wordpress | Wordpress customization | Wordpress How To | Wordpress Mysql Queries | InfoHeap Money

Copyright © 2025 InfoHeap.

Powered by WordPress