Linux常见错误之Could not get lock /var/lib/dpkg/lock - open

在Ubuntu系统上安装vim是遇到的问题:

root@ubuntu:/# vim
The program 'vim' can be found in the following packages:
 * vim
 * vim-gnome
 * vim-tiny
 * vim-athena
 * vim-athena-py2
 * vim-gnome-py2
 * vim-gtk
 * vim-gtk-py2
 * vim-gtk3
 * vim-gtk3-py2
 * vim-nox
 * vim-nox-py2
Try: apt install <selected package>
root@ubuntu:/# apt install vim
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?
root@ubuntu:/# 

出现这个问题可能是有另外一个程序正在运行,导致资源被锁不可用。而导致资源被锁的原因可能是上次运行安装或更新时没有正常完成,进而出现此状况,解决的办法其实很简单:

在终端输入以下两句命令:

root@ubuntu:/# sudo rm /var/cache/apt/archives/lock
root@ubuntu:/# sudo rm /var/lib/dpkg/lock

执行之后即可再次安装vim文本编辑器了。

 

posted @ 2017-06-10 01:00  远近啊  阅读(1183)  评论(0编辑  收藏  举报