Apt is a popular package management module in Linux, that allows you to install, upgrade, update and remove packages. Sometimes, when you run apt-get command, you may get the error ‘dpkg was interrupted, you must manually run sudo…’. In this article, we will learn how to fix this error in Linux.
How to Fix dpkg Was Interrupted, You Must Manually Run Sudo
This error mostly occurs after you have updated or upgraded your Linux system. It happens when dpkg installation gets interrupted due to some reason or the other and the installation remains incomplete. Here are the steps to fix it.
1. Delete Updates
Open terminal and run the following command to delete downloaded updates from your system.
$ cd /var/lib/dpkg/updates $ sudo rm *
This will delete any incomplete updates that could not be installed on your system.
2. Try Update & Upgrade Your System
Run the following commands to update and upgrade your system.
$ sudo apt update $ sudo apt upgrade
If all is well, your system should update & upgrade properly. If you get the message ‘E: Could not get lock /var/lib/dpkg/lock’ it means some other program is updating or upgrading the system or installing another package.
In such cases, check if some other process is locking dpkg files. If so, wait for the installation to complete.
3. Check if dpkg files are locked
Run the following command to check if dpkg files are locked.
$ ps aux | grep -i apt
Ideally, you should get only one output shown below. If you see any more lines in output, note down the PIDs of those processes and use kill command to kill those processes. Those processes are the ones locking your dpkg files.
S+ 19:16 0:00 grep --color=auto -i apt
Once you have killed locking processes, or if you don’t find any, run the following command to remove locks.
$ sudo rm /var/lib/apt/lists/lock $ sudo rm /var/cache/apt/archives/lock $ sudo rm /var/lib/dpkg/lock
Next, try running the dpkg –configure specified by the original error message.
$ sudo dpkg --configure -a
Finally, try again to update & upgrade your system.
$ sudo apt update $ sudo apt upgrade
This time the updates should work properly.
In this article, we have learnt how to fix the error ‘dpkg was interrupted…’ which tends to break apt-get command in Linux. It is basically because dpkg gets locked due to some interruption causing the installation to get locked. You can use these steps in all Ubuntu/Debian systems.
Also read:
How to POST JSON Data in cURL
How to Store JSON to File in Python
How to Handle Multiple Exceptions in Python
How to Make File Executable in Linux
How to Recursively Change Folder Permission in Linux
Related posts:
Sreeram has more than 10 years of experience in web development, Python, Linux, SQL and database programming.
You won’t believe how many issues you helped me resolve on my Xfce Ubuntu studio 20.04 lts distro. And to think of it the issue, in my case, was so small:
“”t happens when dpkg installation gets interrupted due to some reason or the other and the installation remains incomplete.
Thanks a lot
This fixed my dpkg interrupted right way, I installed the system yesterday and it was taking hours, I am not kidding, up to 8 hours to update, just to finish with the error. This time the update went extremely fast!!! Thanks!!!!
THANK YOU SO MUCH! THIS “HOW TO” REALLY HELPED!
You saved me! Thank you!!!!
Hello,
Thank you!! Simple and effective.
Hello,
Thank you!! Simple and effective.
Thank you for posting this.
waooo Thanks for helping
Thank you so much it really helped me do much