How to Install and Uninstall zerofree on Ubuntu 22.04

Updated: September 9, 2022

Zerofree finds the unallocated blocks with non-zero value content in an ext2, ext3 or ext4 file-system and fills them with zeroes (zerofree can also work with another value than zero). This is mostly useful if the device on which this file-system resides is a disk image. In this case, depending on the type of disk image, a secondary utility may be able to reduce the size of the disk image after zerofree has been run. Zerofree requires the file-system to be unmounted or mounted read-only. I will show you how to install zerofree on Ubuntu 22.04 in this guide.

Prerequisites to install

  • Operating system: zerofree needs Ubuntu 22.04 to work
  • Privileges: Check that you can run sudo commands.

Prerequisites to install zerofree on Ubuntu 22.04

Install zerofree Ubuntu 22.04

zerofree is one of the popular ways on Ubuntu now so that this tutorial will show you some ways to install it. Choose the one that you think is easy and you can follow.

Install zerofree using APT

This is a popular method for installing any Ubuntu packages because it is simple to understand, even if you are a Linux beginner. Following these instructions to get zerofree on your Ubuntu.

Step 1: Update the APT database to download new packages from Ubuntu. Opening the terminal and executing the following Linux command:

sudo apt-get -y update

Step 2: Start installing the packages on Ubuntu 22.04. You can now install zerofree Ubuntu by executing this command in the terminal.

sudo apt-get -y install zerofree

Install zerofree using Aptitude

If you haven’t already installed Aptitude on Ubuntu, run this command to do so.

sudo apt install aptitude

After that, you can now install zerofree, just following these steps:

Step 1: Update the APT database to download new packages from Ubuntu. Launch the terminal and enter the following Linux command:

sudo apt update

Step 2: Start the package installation on Ubuntu 22.04. After updating the system, you can install zerofree Ubuntu by executing this command in the terminal.

sudo aptitude -y install zerofree

Uninstall zerofree on Ubuntu 22.04

Have you ever considered how challenging it might be to uninstall an application from Ubuntu? You’re wrong, anyone can easily uninstall any program, not just a zerofree.

You can uninstall zerofree on Ubuntu by running this command if you installed it using APT or Aptitude.

sudo apt remove --auto-remove zerofree

If you want to uninstall zerofree and remove its data and dependencies, you can also run the following command:

sudo apt autoremove --purge zerofree

Conclusion

In this guide, I showed you ways to install zerofree on Ubuntu 22.04 and ways to uninstall zerofree too. Please contact me if you require any assistance. I’d be delighted to respond.