Before we get into Linux jargon and troubleshooting, let’s look at what exactly dpkg is. So, in simple words – dpkg is a package manager for Debian-based Linux distribution. If you are still confused, don’t worry; we will explain it from scratch. In this article, we will explain what does dpkg configure do and the usage of this command.
What is dpkg Command?
Let’s start with the basics, assuming you are using Debian, as dpkg configure is used in Debian-based systems. That’s why you are here to learn about this command. As said above, it is a package manager used for Debian.
So, what is a package manager? If you use Linux-based operating systems, you will often hear the term “package manager” term.
You probably have found .deb files (or packages) in your operating system. These files are called packages in general language. A package carries all types of files that come with a particular type of application.
The package manager is used to manage these packages. For the Debian system, we can use the dpkg command as a package manager for Installing, removing, and upgrading packages in Debian and Debian-based systems.
How to Use dpkg Configure
We use the dpkg command to manage packages on a Linux system, so let’s discuss how we can use dpkg configure easily.
Installing Program Using Dpkg Command
Here is the command to install a program by using dpkg:
For example, we are installing Google Chrome using dpkg command:
This way, you can install multiple applications using this command.
Removing a Program
You can list down the installed packages on your system by using the following command:
Let’s say we have to remove the chrome package:
Configuring a Package
Dpkg –configure one of the popular commands used to configure unpacked programs or packages.
Configuration command is used to unpack and configure the package. You can unpack packages with the following command:
Now, you can configure the package you have recently unpacked above. To configure it, use the following command:
Troubleshooting: Dpkg was Interrupted
This error often appears when we are installing a new program or upgrading an old one. This might happen because you might not configure some of your packages properly, or background processes might be using the same file.
A program Installation goes through the following steps in Debian systems.
- 1It extracts the files from the package.
- In case the app is already installed on the system, it initiates a new installation.
- The file unpacking starts along with backup. In case program installation gets interrupted for any reason, the system can start a new installation again.
- Lastly, the configuration process gets executed
Sometimes, if the program doesn’t get properly executed, it throws the error mentioned above, and it will create issues while installing or updating programs. Now execute the following command for fixing this error:
When we run -a or –pending parameter with dpkg command rather than providing package name, all unpacked, but unconfigured packages are configured.
Now, start the installation or update process again to check if it is working or not. If it persists, you can try the following solutions.
Run the following command to remove the updates first:
$ sudo rm *
Now, try to install or update the app again. For that, we will use the following command:
$ sudo apt upgrade
If the system still throws errors, then it is because the system or other programs are using the file to update applications or the system, resulting in the locking of dpkg files.
When two processes simultaneously use the same file, the system locks the file, preventing unknown errors. You can check if the system is locking the dpkg file. Enter this command to check further:
After running the above command, if you see the result like usr/lib/apt/apt.systemd.daily lock_is_held update, this means the file is being used in another process run in the background.
It would help if you either waited to finish the background process or manually check and remove the locked files using the following command.
To check all the locked dpkg files, we will use the lsof command. lsof command list all the services running in the system. Therefore, we have used the following command one by one to get processes holding the dpkg file.
$ sudo lsof /var/lib/apt/lists/lock
$ sudo lsof /var/cache/apt/archives/lock
You will see that the command you have just entered above throws the one or more processes with the ID that you can terminate using the force kill command.
Also, you can remove the lock files with these commands:
$ sudo rm /var/cache/apt/archives/lock
Finally, run this command to initiate the update process.
As you know, the “dpkg was interrupted” error occurs when two processes run to the same program. We will terminate the service or process locking the dpkg file using the following command on the command line terminal with this method.
Run this command to get services using the dpkg file in the background.
The command mentioned above will show you services running along with a unique ID as following:
Process 2: 1234 0.0 0.0 12×× ××××pts/3 .....
In the above example, 1234 is our ID, so you will see the different IDs in the output. We will use these IDs to kill the running processes. To kill or terminate the particular process, enter the following command:
Now, rerun the following command to check if the process is still running.
If the process still appears on the system, you have to force kill it using the following command:
Another command you can use to terminate all the services using the dpkg file is:
We have a long list of Dpkg commands used for various operations on a particular file or package. Still, we have focused only on the dpkg –configure command in this write-up. We have explained the purpose of dpkg –configure while covering the use of dpkg commands on Debian-based systems.
Frequently, users end up getting configuration problems when installing a new program or updating an application. We also have described the reasons that cause such errors. Therefore, we have provided all the possible solutions to overcome this problem.
We hope you have found this article helpful and informative. If you still have any queries on suggestions, please let us know in the comment section.