2
(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:~$ 

I tried this but didn't work. How can I fix this?

2
  • Use root, not sudo. I've seen all kinds of apt failures when sudo is used instead of proper root.
    – Lizardx
    Dec 16, 2019 at 0:52
  • Simply retrying the command may fix the issue, the locks are there to prevent two things trying to update at the same time. If that fails to resolve the issue then check that the directory /var/lib/dpkg exists (if it doesn't then stop immediately) and see what fuser /var/lib/dpkg/lock-frontend says. Hopefully it will give you one or more numbers (process ids). Use ps -lp 1234 (change 1234 to the numbers from fuser) and see if you want to kill these processes. and then try again.
    – icarus
    Dec 16, 2019 at 2:07

3 Answers 3

6

Your apt-get install --reinstall command doesn't have a sudo in front of it.

A command such as sudo x && y only runs the x command under sudo; the y command runs with normal user privileges.

So if you want to use that syntax you should do sudo x && sudo y.

3

It worked with the below one on Kali Linux

sudo apt-get update && sudo apt-get upgrade -y
3
  • Hello! Could you clarify what worked? Was you able to skip reinstalling a package when apt complained that you need to reinstall it? Oct 30, 2020 at 7:40
  • @Roman Riabenko - I was trying to upgrade libraries, packages in Kali and hit with the "Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?".
    – Madhu
    Nov 18, 2020 at 4:26
  • So, your problem was that you skipped the second sudo the same way as described in the question and you fixed it by adding that second sudo after && as described in the most upvoted answer here. Right? Nov 18, 2020 at 6:36
0

I know this is pretty late but typing sudo su And retrying the command you were going to do is more simple.

1
  • 2
    Notice that Stephen's answer points out the lack of sudo before the apt-get install --reinstall ... portion, which avoids an unnecessary full su to root.
    – Jeff Schaller
    Aug 29, 2020 at 20:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .