Method to solve the problem of automatic updating software package in Debian system

  • 2021-07-10 21:20:04
  • OfStack

I don't know when I started. After my computer was turned on and connected to the network every day, I kept downloading data. The status bar showed that the network speed reached 1 to 2 megabytes per second. I didn't care much at first, but later, because the bandwidth was occupied by this inexplicable download, I didn't even browse the web page normally, so I decided to solve this problem. Record 1 below the process of solving this problem.

First of all, I used a real-time network speed monitoring program named nethogs to see which process is occupying the bandwidth, and found that it is the APT packet management tool of the system that occupies the bandwidth. I think it must be the system that is performing automatic updates. After killing this process, I went to Google to find out how to turn off the automatic update of APT package management tool. Most of the solutions provided by people on the Internet are as follows: modify the configuration file of APT.

The APT configuration file for automatic updates is located in "/etc/apt/apt. conf. d/20auto-upgrades", where the


APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";

Change to


APT::Periodic::Update-Package-Lists "0";
APT::Periodic::Unattended-Upgrade "0";

Among them

APT:: Periodic:: Update-Package-Lists; Automatically run apt-get update every 1 day, with 1 enabled and 0 disabled. APT:: Periodic:: Unattended-Upgrade; Run the unattended-upgrade security upgrade script every 1 day, with 1 enabled and 0 disabled.

However, it is useless. APT performs automatic update again after booting on the second day. What is even more strange is that it will run again soon after killing APT process. Then I realized one thing, APT is not automatically transferred into memory to run, 1 must be another process called it. After opening the process manager, check the dependencies of APT processes, and find that it really has a parent process named packagekit. I checked that packagekit is a system designed to simplify the installation and update of software for Linux distribution. It provides a front-end for different package management tools, and you can use it to manage software packages in different Linux distributions.

My system starts the packgekit service on boot by default. Check the startup unit of packagekit:
cat /lib/systemd/system/packagekit.service


[Unit]
Description=PackageKit Daemon
# PK does not know how to do anything on ostree-managed systems;
# currently the design is to have dedicated daemons like
# eos-updater and rpm-ostree, and gnome-software talks to those.
ConditionPathExists=!/run/ostree-booted

[Service]
Type=dbus
BusName=org.freedesktop.PackageKit
User=root
ExecStart=/usr/lib/packagekit/packagekitd

This unit will be started every time the system starts up, and the command /usr/lib/packagekit/packagekitd will be executed, and packagekit will call APT to download the software package that needs to be updated during operation.

Knowing these problems will solve, disable this service: systemctl disable packagekit. service.

Or simply delete packagekit. service from the/lib/systemd/system/ directory (of course, you can also move this file somewhere else and put it back when you need it later)

Since then, the system has never performed automatic updates.

[Attached]

nethohs is a command line tool that can monitor the network in real time according to the process. It can dynamically display the network traffic information of the process that is communicating at a certain time.
Under Debian/Ubuntu, install it using apt-get install nethogs.
Or compile and install:


wget -c https://github.com/raboof/nethogs/archive/v0.8.5.tar.gz
tar xf v0.8.5.tar.gz 
cd ./nethogs-0.8.5/
make && make install

Dependent libraries need to be installed if compilation fails


apt-get install libncurses5-dev libpcap-dev

Use


root@zsimline$ nethogs
NetHogs version 0.8.5-2+b1
PID USER  PROGRAM          DEV SENT   RECEIVED 
2181 mxsyx /usr/share/code/code    usb0 0.449  0.900 KB/sec
1598 mxsyx /usr/lib/chromium/chromium usb0 0.031  0.018 KB/sec
?  root  unknown TCP           0.000  0.000 KB/sec

 TOTAL                   0.480    0.917 KB/se

Designated network card


root@zsimline$ nethogs wlan0 #  Eavesdropping wlan0
root@zsimline$ nethogs -a  #  Monitor all network cards 

Specify refresh frequency-d seconds (default is 1)


root@zsimline$ nethogs -d 2

Specify refresh times-c number (default unlimited)


root@zsimline$ nethogs -c 10

Interactive mode

After entering nethogs, you can use the following interactive commands:

q: Exit
s: Sort by Send Traffic
r: Sort by Traffic
m: Modified network speed units (KB, B, MB) and KB/s


Related articles: