18
December
2023
22:30

Solving problems when starting apt-get update: apt-news.service and esm-cache.service services not found

18 December 2023 22:30

At the launch of apt-get update, an error may occur Failed to start apt-news.service: Unit apt-news.service Not Found. Failed to start esm-cache.service: Unit esm-cache.serVice Not Found.

Solution:

Move the file 20apt-esm-hook.conf to another folder, to hide the conf file from the "apt" package installer:

cd /etc/apt/apt.conf.d/
sudo mkdir off
sudo mv 20apt-esm-hook.conf off

In another folder with name "off".

What is contained in the file 20apt-esm-hook.conf ?

APT::Update::Pre-Invoke {
   "[ ! -e /run/systemd/system ] || [ $(id -u) -ne 0 ] || systemctl start --no-block apt-news.service esm-cache.service || true";
};

binary::apt::AptCli::Hooks::Upgrade {
   "[ ! -f /usr/lib/ubuntu-advantage/apt-esm-json-hook ] || /usr/lib/ubuntu-advantage/apt-esm-json-hook || true";
};

As can be seen from the text 20apt-esm-hook.conf it is associated with the package "Ubuntu Advantage", which I am Deleted earlier.

Addition: Prohibition of launching services

Even if the services "apt-news.service", "esm-cache.service" are disabled, It can be launched through another service. Complete disabling is possible using the "mask" option.

sudo systemctl mask apt-news.service
sudo systemctl mask esm-cache.service

(Symbolic links to services are in the folder /etc/systemd/system).



Related publications