无法获取 dpkg 前端锁 (/var/lib/dpkg/lock-frontend),您是 root 吗?

rus*_*ara 1 root dpkg lock

(base) rusiru@rusiru-X556UV:~$ sudo apt-get upgrade
Reading packages lists... Done
Building dependency tree
Reading state information... Done
E: The package packettracer needs to be installed, but I can't find an archive for it.
(base) rusiru@rusiru-X556UV:~$ sudo apt-get update
Hit:1 http://security.ubuntu.com/ubuntu focal-security InRelease
Hit:2 http://lk.archive.ubuntu.com/ubuntu focal InRelease
Hit:3 http://lk.archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:4 http://lk.archive.ubuntu.com focal-backports InRelease
Reading package lists... Done
(base) rusiru@rusiru-X556UV:~$ sudo apt-get upgrade
Reading packages lists... Done
Building dependency tree
Reading state information... Done
E: The package packettracer needs to be installed, but I can't find an archive for it.
(base) rusiru@rusiru-X556UV:~$ sudo apt-get update && apt-get install --reinstall packettracer
Hit:1 http://security.ubuntu.com/ubuntu focal-security InRelease
Hit:2 http://lk.archive.ubuntu.com/ubuntu focal InRelease
Hit:3 http://lk.archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:4 http://lk.archive.ubuntu.com focal-backports InRelease
Reading package lists... Done
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?
(base) rusiru@rusiru-X556UV:~$ sudo dpkg -l packettracer
Desired-Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/half-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version      Architecture Description
+++-==============-============-============-=================================
pHR packettracer   7.3.0        amd64        (no description available)
(base) rusiru@rusiru-X556UV:~$ sudo apt-get upgrade
Reading packages lists... Done
Building dependency tree
Reading state information... Done
E: The package packettracer needs to be installed, but I can't find an archive for it.
(base) rusiru@rusiru-X556UV:~$ 
Run Code Online (Sandbox Code Playgroud)

我试过这个,但没有用。我怎样才能解决这个问题?

Ste*_*ris 6

您的apt-get install --reinstall命令前面没有 sudo。

诸如sudo x && y 运行;x下的命令的命令 sudoy命令以普通用户权限运行。

因此,如果您想使用该语法,则应该执行sudo x && sudo y.