policy-rc.d-declarative command not found

In this troubleshooting guide we learn how to fix policy-rc.d-declarative command not found error message

Introduction

When you run more command in linux terminal / console, you get the following error message

policy-rc.d-declarative: command not found

or when using sudo you get the following error message

sudo: policy-rc.d-declarative: command not found

Solutions to policy-rc.d-declarative: command not found

How To Fix policy-rc.d-declarative: command not found in Ubuntu / Debian / Kali Linux / Raspbian

In Ubuntu policy-rc.d-declarative is provided by policy-rcd-declarative package.

policy-rcd-declarative is:

Debian policy states that packages providing system services need to start those services by default, and that the starting of the service should be done by way of the /usr/sbin/invoke-rc.d script. This script will execute a program /usr/sbin/policy-rc.d if it exists, allowing the local system administrator to override behaviour if wanted by creating a policy script accordin to the interface specified and installing it under the correct name. This interface is however somewhat problematic, as explained in https://bugs.debian.org/911290.

This package attempts to provide a solution by shipping a policy-rc.d script that allows system administrators to define policies in a declarative way through one or more configuration files, rather than providing one script that may be overwritten.

To fix this problem, we can install more using the command below.

sudo apt-get -y install policy-rcd-declarative

This command might take some time to finish depending on your machine internet connection.

You can also use apt command to install policy-rcd-declarative.

sudo apt -y install policy-rcd-declarative

Or if you have aptitude installed you can use the following command.

sudo aptitude install policy-rcd-declarative

Summary

In this tutorial we learn how to fix policy-rc.d-declarative command not found error in Ubuntu / Debian / Kali Linux or Raspbian distribution.