使用 Ubuntu 的 apt 经常碰到这个问题:
root@ubuntu:/root# sudo apt-get install -y httpd
E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?
网上都说 kill apt 进程甚至去删 lock 文件,其实是错误的。这是因为 update-manager
自动更新导致的。正确做法是禁用服务:
sudo systemctl disable apt-daily.service
sudo systemctl disable apt-daily.timer
sudo systemctl disable apt-daily-upgrade.timer
sudo systemctl disable apt-daily-upgrade.service
Do I really need apt-daily.service and apt-daily-upgrade.service?