# ubunt Could not open lock file/var/lib/dpkg/lock的解决办法

> ubunt Could not open lock file/var/lib/dpkg/lock的解决办法？ 在ubuntu系统中利用apt-get install something的时候，有时候会出现无法获得锁的权限问题。这是因为有另外…

- 原文：https://www.l2qq.com/article/111
- 发布：2020-04-16T07:55:50Z
- 更新：2020-06-12T09:51:01Z
- 作者：l2qq

---

ubunt Could not open lock file/var/lib/dpkg/lock的解决办法？
在ubuntu系统中利用apt-get install something的时候，有时候会出现无法获得锁的权限问题。这是因为有另外一个进程在占用锁。类似以下的错误提示：
```
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
W: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permission denied)
W: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission denied)
ubuntu@VM-0-5-ubuntu:~$ apt-get upgrade -y
E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?
```
解决办法：
```
sudo rm -rf /var/lib/dpkg/lock
sudo rm -rf /var/cache/apt/archives/lock
sudo apt-get update
sudo dpkg --configure -a
```
运行以上四条命令即可
安装git提示
E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?
原因：
输入命令： apt-get install git后提示权限不够

解决方法，在命令前加 sudo即可
```
sudo apt-get install git
```
