• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
sharadchhetri

sharadchhetri

Tutorials On Linux, Unix & Open Source

  • Home
  • Linux Commands
  • Resources
    • Learn Linux
  • My WordPress plugins

Prevent starting service after package installation on Ubuntu / Debian

February 21, 2015 by Sharad Chhetri

In this tutorial we will learn, how to prevent starting service after package installation on Ubuntu / Debian . In simple way, we will use the policy.rc.d to control the behavior of
invoke-rc.d for every initscript id and action .

We will create a executable script called policy.rc.d and write the exit code 101 in it.

If you are wondering what is exit 101 , so here is the answer.
Exit status code 101 means action forbidden by policy.

Why want to prevent starting of service after its package installation ?
The reason is – for eg. if we install apache2 in system, it will automatically get started after installation. But we do not want to start apache2 after installation. Similarly there are other services which should not not start when we install their related packages.

How to prevent starting service after package installation

1. Create policy.rc.d executable file.

vi /usr/sbin/policy-rc.d 

Write the below given exit status in policy.rc.d file

#!/bin/sh
exit 101

Save and exit.

2. Make the file /usr/sbin/policy-rc.d executable.

chmod +x /usr/sbin/policy-rc.d

yes, that’s it. We have completed our task.

Now try installing any one of the package like, apache2,nginx,mysql,mariadb etc. After installation , their services will not start.

Given below is reference from our system when we install apache2 package. We are sharing only tail output of apt-get install apache2 php5-fpm command.
In below given output, you can read that policy.rc.d denied execution of restart.

invoke-rc.d: policy-rc.d denied execution of restart.
apache2_invoke: Enable module php5
invoke-rc.d: policy-rc.d denied execution of restart.
Processing triggers for libc-bin (2.19-0ubuntu6.4) ...
Processing triggers for php5-fpm (5.5.9+dfsg-1ubuntu4.6) ...
invoke-rc.d: policy-rc.d denied execution of restart.
invoke-rc.d: policy-rc.d denied execution of start.

Reference : Read more about policy.rc.d

Share this:

  • Twitter
  • Facebook
  • More
  • Print
  • Email
  • LinkedIn
  • Reddit
  • Tumblr
  • Pinterest
  • Pocket
  • Telegram
  • WhatsApp
  • Mastodon

Related posts:

  1. How to find installation date and time of rpm package
  2. How to test rpm package before installation
  3. Completely remove package on Ubuntu / Debian by apt-get
  4. check_openerp nagios plugin for openerp service check
  5. SELINUX : squid service failed to start/restart
  6. Upgrading MySQL 5.1 to 5.6 service failed to start
  7. Debian Wheezy 7.1 package not found
  8. Installation of OpenERP 7.0 in Ubuntu
  9. How To Always Install Latest Git Package In Ubuntu Operating System
  10. Create bootable usb key for CentOS 7 installation

Filed Under: Linux Tagged With: policy.rc.d, ubuntu

Primary Sidebar

Our Social Media Presence

  • Facebook
  • GitHub
  • Twitter

Linux Command

What is Linux Internal And External Command

Linux Basic Commands With Examples For Every Beginner

tr command to convert lines to space , tab and vertical tab

smbpasswd command not found on CentOS 7 and RHEL 7

Solution : semanage command not found

Unix / Linux : How to print duplicate lines from file

More Posts from this Category

You Might Like These Articles!

simplecodesyntax wordpress plugin

SimpleCodeSyntax : My Another WordPress Plugin

Install Nginx

How To Install Nginx On Ubuntu 22.04 LTS

Install Latest Git package in Ubuntu Operating System

How To Always Install Latest Git Package In Ubuntu Operating System

Bash script for installing VirtualBox on Ubuntu 22.04 LTS Desktop

Install VirtualBox On Ubuntu 22.04 LTS Desktop (Bash Script)

libfuse

dlopen(): error loading libfuse.so.2 – Got Error On Ubuntu

Failed to open/create the internal network

VirtualBox Error: Failed to open/create the internal network

Always Useful Tips And Tricks

How to change smtp port number 25 in postfix

Run the script using nohup without hitting enter key two times

How to change hostname in Ubuntu 12.04 and 12.10 without system restart

Forward all incoming emails to other SMTP server or gateway

Print double hyphen sign simultaneously in post of Octopress

How to set JAVA environment variables in Linux

find command to search keyword in files recursively in linux

Explore 90+ Article On "Linux Tips And Tricks"

Copyright © 2023 ยท
The material in this site cannot be republished either online or offline, without our permission.
Proudly Blogging From Bharat.

  • Contact
  • About Me
  • My WordPress plugins
  • Privacy Policy