Software & AppsOperating SystemLinux

Downgrading Packages with apt-get

Ubuntu 1

In the world of Linux, apt-get is a powerful package management command-line tool used in Debian-based systems like Ubuntu. It handles the installation, upgrade, and removal of software packages. But what if you need to downgrade a package to an older version? This article will guide you through the process of downgrading packages using apt-get.

Quick Answer

To downgrade packages with apt-get, first check the available versions using apt-cache showpkg <package-name>. Then, remove the current version with sudo apt-get remove <package-name> or sudo apt-get purge <package-name>. Finally, install an older version using sudo apt-get install <package-name>=<package-version-number>. If you encounter issues, try using aptitude instead. To prevent automatic upgrades, use apt-mark hold <package-name>. If you’ve upgraded a package from a PPA, use ppa-purge to downgrade it.

Understanding apt-get

Before diving into the downgrading process, it’s important to understand what apt-get is. apt-get is a command-line tool that interacts with the Advanced Packaging Tool (APT) on Debian-based systems. It’s used to handle packages, and it can resolve and download dependencies automatically.

Checking Available Versions

Before you can downgrade a package, you need to know which versions are available. You can do this using the apt-cache showpkg <package-name> command. Replace <package-name> with the name of the package you want to downgrade. This command will list all the available versions of the package.

apt-cache showpkg <package-name>

Removing the Current Version

The next step is to remove or purge the current version of the package. You can do this with the sudo apt-get remove <package-name> or sudo apt-get purge <package-name> commands. The remove command will remove the package but leave configuration files, while the purge command will remove everything related to the package, including configuration files.

sudo apt-get remove <package-name>

or

sudo apt-get purge <package-name>

Installing an Older Version

After removing the current version of the package, you can install an older version. You can do this by specifying the version number in the apt-get install command like this: sudo apt-get install <package-name>=<package-version-number>. Replace <package-name> with the name of the package and <package-version-number> with the version number you want to install.

sudo apt-get install <package-name>=<package-version-number>

Using aptitude for Downgrading

If you encounter any issues with downgrading using apt-get, you can try using aptitude. aptitude is another package management tool that can handle dependencies and downgrades better in some cases. To use aptitude, run sudo aptitude install <package-name>=<package-version-number>.

sudo aptitude install <package-name>=<package-version-number>

Preventing Automatic Upgrades

Once you’ve downgraded a package, you might want to prevent it from being automatically upgraded in the future. You can do this using the apt-mark hold <package-name> command. This command will “hold” the package at its current version, preventing apt-get from upgrading it.

sudo apt-mark hold <package-name>

Downgrading Packages from a PPA

If you’ve upgraded a package using a Personal Package Archive (PPA), you can downgrade it using ppa-purge. First, install ppa-purge by running sudo apt-get install ppa-purge. Then, remove the PPA using sudo ppa-purge ppa:user/ppa-name. This will automatically downgrade the software to the version that was originally shipped with your Ubuntu distribution.

sudo apt-get install ppa-purge
sudo ppa-purge ppa:user/ppa-name

Conclusion

Downgrading packages with apt-get is a straightforward process once you understand the steps involved. Remember to check the available versions first, then remove the current version before installing the older version. If you encounter issues, try using aptitude instead. And if you want to prevent automatic upgrades, use the apt-mark hold command. If you’ve upgraded a package from a PPA, use ppa-purge to downgrade it. With these steps, you can effectively manage your software packages and ensure your system runs smoothly.

Can I downgrade any package using apt-get?

Yes, you can downgrade any package that has multiple versions available in the package repository. You just need to know the name of the package and the version number you want to install.

How can I check the available versions of a package?

You can use the apt-cache showpkg <package-name> command to check the available versions of a package. It will list all the versions along with their dependencies.

What’s the difference between `apt-get remove` and `apt-get purge`?

The apt-get remove command will remove the package but leave the configuration files intact. On the other hand, the apt-get purge command will remove everything related to the package, including the configuration files.

Can I install a specific version of a package using apt-get?

Yes, you can install a specific version of a package using apt-get install <package-name>=<package-version-number>. Just replace <package-name> with the name of the package and <package-version-number> with the desired version number.

What should I do if I encounter issues with downgrading using apt-get?

If you encounter issues with downgrading using apt-get, you can try using aptitude instead. aptitude is another package management tool that can handle dependencies and downgrades better in some cases.

How can I prevent a downgraded package from being automatically upgraded in the future?

To prevent a downgraded package from being automatically upgraded, you can use the apt-mark hold <package-name> command. This will "hold" the package at its current version, preventing apt-get from upgrading it.

How can I downgrade a package that I upgraded using a Personal Package Archive (PPA)?

To downgrade a package that you upgraded using a PPA, you can use ppa-purge. First, install ppa-purge by running sudo apt-get install ppa-purge. Then, remove the PPA using sudo ppa-purge ppa:user/ppa-name. This will automatically downgrade the software to the version that was originally shipped with your Ubuntu distribution.

Leave a Comment

Your email address will not be published. Required fields are marked *