問題描述
今天在使用 sudo sudo apt install node.js 的時候出現錯誤。錯誤如下:
ubuntu:~$ sudo sudo apt install node.js
E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?
問題產生原因
apt 進程還在運行,導致文件被鎖定。
解決方法
找到 apt 進程,並將其殺死。
$ ps -au|grep apt
root 1051 0.0 0.0 62860 4304 pts/0 T 11:35 0:00 sudo sudo apt install node.js
root 1052 0.0 0.0 62860 4208 pts/0 T 11:35 0:00 sudo apt install node.js
root 1053 1.0 1.1 145388 90864 pts/0 T 11:35 0:00 apt install node.js
ubuntu 1283 0.0 0.0 13772 1068 pts/0 S+ 11:36 0:00 grep --color=auto apt
ubuntu@VM-16-11-ubuntu:~$ sudo pkill -9 apt
其實直接 sudo pkill -9 apt 就可以了。