Have you ever broken apt?

For seasoned Linux professionals, it’s quite common (about every half year) to unwittingly break apt.

What Areaptanddpkg?

Tux mascot jumping from Windows to Linux.

If you’re using a Debian-based distribution like Ubuntu or Mint, your gear usesaptto handle packages.

The package manager for Debiandpkgis an alternative to managing packages on Debian-based installations.

Or, perhaps, a package installation accidentally got interrupted.

synology nas

If so, then …

Welcome todpkg

When youraptis broken, it’s no fun.

If it’s really broken, it’s even less fun.

This is where we come todpkg.

Article image

Let’s dive in.

BasicdpkgUsage

We can see the packages currently on the system by simply executing

.

In this case, we’re searching for the textgnome-calculator.

Our first dpkg run

The secondary line/command under it shows a version that we would normally use.

Once someone is familiar with the syntax of thedpkgoutput, the first five lines are often unnecessary.

If you visually follow the lines, you’ll see how they connect quickly.

dpkg -l | grep ‘mintwelcome’ output

As ourgnome-calculatoris successfully installed without any current errors, there’s no third column code underErr?=.

We also note here thatuppercase=badis written in the short info relating to the third column.

As previously stated, in our case, it’s blank.

Purging ‘mintwelcome’ configuration files with dpkg

The first column shows the desired status, and the second column shows the current status.

It basically means thateverything is fine, that the package is installed, and that there are no issues.

For example, consider howfrefers tohalF-conf, noting the uppercaseFin the same.

dpkg listing output for javascript-common configuration files

Let’s now take a look at another output to compare.

Here, we see the interesting result ofrc, whereiiused to be for thegnome-calculator.

Let’s purge it!

dpkg -l | grep ‘javascript’ output

In the first command, we can take a stab at purgemintwelcomewithout usingsudo.

However, this won’t work.

You need super-user/root-level privileges to uninstall (or install or purge) packages.

We can run again usingsudo, and our package will be purged.

Safe to remove or not?

you might see how great power comes with great responsibility, as always in life.

The decision to remove it or not is yours.

Was it the best course of action?

Also, note that there is really nothing broken here.

It’s fine to leave the configuration files for this seemingly removed package.

It’s a good one to keep in mind when usingdpkg.

Secondly, it’s important to remember thataptis a package manager that keeps all connections (i.e.

versions and dependencies) between packagesin mindwhen installing, uninstalling, or purging packages.

This isn’t the case fordpkg, which is much more package-based.

There’s more granularity, but also more risk of breaking things.

Thirdly, most Linux packages havemanydependencies.

To remove/uninstall a package rather than purge it (i.e.

To verify a package, use–verify(or-V).

For more options, seeman dpkgexecuted from your terminal.

There are also specific, more complex commands that can be used for various packaging system issues.

Often, someone else has already run into it and documented the details.

Remember, in these complex package management issue debugging situations, with great power comes great responsibility.