Debian apt install Could not get lock 错误

full debian apt could not get lock

我在Debian10安装Mariadb时遇到一个错误

【国内直连ChatGPT 29元起】
国内直连ChatGPT,Plus会员每月29元起,支持最新o1模型探索更多领域,无需注册OpenAI账号。

$ apt install mariadb-server
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为了防止冲突,在运行期间会生成相关的lock文件,当其他人在这期间运行apt命令时会检测到lock文件是否存在从而保证同一时间只能运行一个apt程序。这个设计理论上是完美的,但也会有意外,比如在apt某次运行时意外退出没有来得及清理lock文件,那么这就造成系统误判。

所以要么等待以上两种情况处理完成,如果你确定它没有在Terminal里运行的话,可以通过以下方式重置一下

如果你有killall命令,执行一下

killall apt apt-get

如果仍然不能工作,就只能强制删除lock文件

rm /var/lib/apt/lists/lock
rm /var/cache/apt/archives/lock
rm /var/lib/dpkg/lock*

然后需要重新配置一下软件包

dpkg --configure -a

然后再进行update

apt update

假如成功的话,就可以继续安装MariaDB了

$ apt install mariadb-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  galera-3 gawk libaio1 libcgi-fast-perl libcgi-pm-perl libconfig-inifiles-perl libdbd-mysql-perl libdbi-perl libencode-locale-perl libfcgi-perl libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl
  libhttp-date-perl libhttp-message-perl libio-html-perl liblwp-mediatypes-perl libmpfr6 libreadline5 libsigsegv2 libsnappy1v5 libterm-readkey-perl libtimedate-perl liburi-perl mariadb-client-10.3
  mariadb-client-core-10.3 mariadb-server-10.3 mariadb-server-core-10.3 psmisc rsync socat
Suggested packages:
  gawk-doc libclone-perl libmldbm-perl libnet-daemon-perl libsql-statement-perl libdata-dump-perl libipc-sharedcache-perl libwww-perl mailx mariadb-test netcat-openbsd tinyca
The following NEW packages will be installed:
  galera-3 gawk libaio1 libcgi-fast-perl libcgi-pm-perl libconfig-inifiles-perl libdbd-mysql-perl libdbi-perl libencode-locale-perl libfcgi-perl libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl
  libhttp-date-perl libhttp-message-perl libio-html-perl liblwp-mediatypes-perl libmpfr6 libreadline5 libsigsegv2 libsnappy1v5 libterm-readkey-perl libtimedate-perl liburi-perl mariadb-client-10.3
  mariadb-client-core-10.3 mariadb-server mariadb-server-10.3 mariadb-server-core-10.3 psmisc rsync socat
0 upgraded, 32 newly installed, 0 to remove and 37 not upgraded.
3 not fully installed or removed.
Need to get 22.2 MB of archives.
After this operation, 170 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y

问题解决

分享

TITLE: Debian apt install Could not get lock 错误

LINK: https://www.qttc.net/523-debian-apt-install-could-not-get-lock.html

NOTE: 原创内容,转载请注明出自琼台博客