Removing Orphaned Packages on Debian/Ubuntu With Deborphan

When you install and remove packages on a Debian-based Linux distribution like Debian or Ubuntu, sometimes you end up with orphaned packages - packages that were installed as dependencies for other software but are no longer needed. These orphaned packages can take up disk space and clutter your system. One tool that can help you identify and remove these orphaned packages is Deborphan.

What is Deborphan?

Deborphan is a command-line tool for identifying and removing orphaned packages on Debian-based systems. It analyzes the package dependencies and checks which packages are no longer required by any other installed packages. Once it identifies these orphaned packages, you can choose to remove them, freeing up disk space and keeping your system clean.

Installing Deborphan

Before you can use Deborphan, you need to install it. You can do this using the package manager on your system. Open a terminal and run:

1
2
sudo apt-get update
sudo apt-get install deborphan

Using Deborphan

Once Deborphan is installed, you can start using it to identify and remove orphaned packages. Here are the basic commands:

  1. Identify Orphaned Packages:

    To identify orphaned packages on your system, open a terminal and run:

    1
    
    sudo deborphan

    Deborphan will list all the orphaned packages it finds.

  2. Remove Orphaned Packages:

    To remove the orphaned packages found by Deborphan, you can use the apt-get command. Be careful with this step, as it will permanently remove these packages from your system:

    1
    
    sudo apt-get remove --purge $(deborphan)

    This command will remove all the orphaned packages listed by Deborphan.

  3. Remove Configuration Files (optional):

    If you want to remove the configuration files associated with the removed packages, you can run the following command:

    1
    
    sudo apt-get purge $(deborphan --showconfig)

    This will remove the configuration files for the orphaned packages.

Cleaning Up

After running the above commands, your system should be free of orphaned packages, and you should have reclaimed some disk space. It’s a good practice to periodically run Deborphan to keep your system clean and efficient.

Remember to exercise caution when removing packages, especially if you’re not sure what a package does. Always review the list of packages that Deborphan suggests for removal to ensure that you’re not removing anything critical to your system’s functionality.

Deborphan is a handy tool for maintaining a clean and tidy Debian-based Linux system, and it can help you keep your system running smoothly.

0%