ubuntu使用apt下载文件报错
情况说明
在ubuntu中使用apt安装net-tools插件时发现无法正常安装,已确定网络状况正常。
问题还原
使用apt下载文件报错:
root@ubuntu:/home/sbc# apt install net-tools
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?
查看apt进程:
root@ubuntu:/home/sbc# ps -ef|grep apt
root 920 1 0 22:32 ? 00:00:00 /bin/sh /usr/lib/apt/apt.systemd.daily update
root 930 920 0 22:32 ? 00:00:00 /bin/sh /usr/lib/apt/apt.systemd.daily lock_is_held update
_apt 1570 1557 0 22:34 ? 00:00:01 /usr/lib/apt/methods/http
_apt 1571 1557 0 22:34 ? 00:00:00 /usr/lib/apt/methods/http
root 3124 3076 0 22:47 pts/0 00:00:00 grep --color=auto apt
问题解决
杀光进程:
root@ubuntu:/home/sbc# ps -ef|grep apt|grep -v grep|awk '{print $2}'|xargs kill -9
root@ubuntu:/home/sbc# ps -ef|grep apt
root 3170 3076 0 22:47 pts/0 00:00:00 grep --color=auto apt
删除锁文件:
root@ubuntu:/home/sbc# ls /var/lib/dpkg/
alternatives cmethopt info statoverride triggers
arch diversions lock status updates
available diversions-old parts status-old
root@ubuntu:/home/sbc# rm /var/lib/dpkg/lock
再次执行apt命令,成功安装:
root@ubuntu:/home/sbc# apt install net-tools
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
net-tools
0 upgraded, 1 newly installed, 0 to remove and 299 not upgraded.
Need to get 194 kB of archives.
After this operation, 803 kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu bionic/main amd64 net-tools amd64 1.60+git20161116.90da8a0-1ubuntu1 [194 kB]
Fetched 194 kB in 18s (10.8 kB/s)
Selecting previously unselected package net-tools.
(Reading database ... 125941 files and directories currently installed.)
Preparing to unpack .../net-tools_1.60+git20161116.90da8a0-1ubuntu1_amd64.deb ...
Unpacking net-tools (1.60+git20161116.90da8a0-1ubuntu1) ...
Processing triggers for man-db (2.8.3-2) ...
Setting up net-tools (1.60+git20161116.90da8a0-1ubuntu1) ...