How to Install zlib on Ubuntu 24.04, 22.04, or 20.04 - LinuxCapable (2024)

Zlib is a cornerstone in data compression, offering many applications that underscore its utility in the digital age. Renowned for its efficiency and versatility, zlib facilitates data compression and decompression, making it a vital component for developers, system administrators, and any tech enthusiast looking to enhance their project’s performance or data management capabilities.

Here are some of the reasons you may need to install zlib on your Ubuntu system:

  • Reducing Load Times for Web Applications: Enables data compression, enhancing user experience by speeding up load times.
  • Optimizing Software Development Projects: Essential for projects needing data compression to minimize storage or network transfer loads.
  • Enhancing File Archiving Tools: Relies on zlib’s efficient compression algorithms to support robust archiving solutions.
  • Integrating with Libraries/Frameworks: Utilizes zlib in programming for dependable data handling within various libraries or frameworks.
  • Improving Gaming Applications: Helps minimize game asset size, facilitating faster loading times.
  • Managing Storage in Embedded Systems: Employs compression to manage limited storage capacity effectively.
  • Optimizing Database Management Systems: Applies data compression to backups, significantly saving on storage space.
  • Enhancing Network Programming: Uses data compression to boost data packet transmission speed over networks.

Understanding how to install zlib is not just about executing a series of commands; it’s about equipping your Ubuntu system with a powerful tool that can significantly impact the efficiency and performance of numerous applications.

Next, we will guide you through the installation process.

Prerequisites for Installing zlib

To successfully install zlib on Ubuntu, ensure you meet the following requirements:

Minimum Hardware and Supported Ubuntu Versions

Processor2 gigahertz (GHz) or faster dual-core processor (based on Ubuntu’s minimum requirements)
RAM4 GB or more (based on Ubuntu’s minimum requirements)
Disk Space50 MB of free space
Supported VersionsUbuntu 24.04 (Noble), Ubuntu 22.04 (Jammy), Ubuntu 20.04 (Focal)

Network and Terminal Requirements

Internet ConnectionRequired to download zlib and updates.
Terminal ConventionsAll terminal commands should be run as a regular user with sudo privileges.
CLI CommandsUse the Command Line Interface (CLI) for installation and setup.

Method 1: Install zlib via Ubuntu’s Default Repository

Update Ubuntu Before zlib Installation

Before installing Zlib on your system, it is essential to update your Ubuntu installation to ensure all system packages are up-to-date. This helps prevent potential conflicts and ensures your system’s compatibility with the latest software packages. To update your Ubuntu system, execute the following command:

sudo apt update

If there are any updates available, use the following command to initiate the upgrade process:

sudo apt upgrade

This command will install the latest versions of all packages installed on your system, ensuring a stable and secure environment.

Install zlib on Ubuntu via APT Command

To install the Zlib development package (which contains the header files and libraries necessary for developing software that uses Zlib), run the following command:

sudo apt install zlib1g-dev

This command will install the zlib1g-dev package, ensuring your system has the necessary files to compile and link software using Zlib.

Method 2: Install zlib via Source Archive

This secondary method is to install the latest version of zlib or if you require a specific version of zlib. The only downside is that if you opt for the latest version, you must remember to re-compile any future updates.

Download the zlib source code

First, you must download the zlib source code from the official website. Open a terminal and navigate to the directory where you want to download the source code.

Use the wget command to download the source code from the Zlib website. Replace the {replace with your version downloaded} placeholder with the actual version number or link, as this may change in the future:

wget{replace with your version downloaded}

Or you can alternatively download the source from zlib’s GitHub releases page:

wget{replace with your version downloaded}.gz

An example with zlib 1.3 version release only would be similar too:


Extract zlib source Archive

Once the Zlib source code has been downloaded, you must extract the archive’s contents. This can be done using the tar command:

tar -xvzf v1.3.tar.gz

Note: Remember to replace v1.3.tar.gz with your version. The command is only an example, remember.

Compile and Install zlib

Before you compile and install zlib from the source, ensure that the required dependencies are installed on your system. These dependencies include the build-essential package, which provides essential tools for building software on Ubuntu, and the gcc and make packages. To install these dependencies, run the following command:

sudo apt install build-essential gcc make

Next, navigate to the extracted Zlib source code directory using the cd command:

cd zlib-{replace with your version downloaded}

Now configure the zlib Library:

./configure --prefix=/usr/local/zlib

Now, run the following commands in sequence to compile, and install zlib on your system:

makesudo make install

The ./configure command generates the necessary Makefile based on your system’s configuration, while the make command compiles the Zlib source code. Finally, the sudo make install command installs the compiled Zlib library and header files to the appropriate locations on your system.


In wrapping up, we’ve walked through the steps to get zlib up and running on your Ubuntu system, offering both the straightforward APT method and the hands-on approach of compiling the latest version. Remember, updating your zlib installation ensures you’re leveraging the best in performance and security.

Useful Links

Here are some valuable links related to using zlib:

  • zlib Official Website: Visit the official zlib website for general information, download options, and the latest updates.
  • zlib Manual: Access the zlib manual for comprehensive documentation on using and configuring zlib.
  • zlib How-to Guide: Explore guides for practical instructions and examples on using zlib in your projects.
  • zlib GitHub Releases: Check out the latest zlib releases on GitHub to download the most recent versions and view release notes.
  • zlib GitHub Wiki: Visit the zlib GitHub wiki for additional documentation, tutorials, and community-contributed content.
  • Author
  • Recent Posts

Follow me

Joshua James

Joshua James is an experienced Linux system administrator and the owner of He has written many tutorials and guides to help users understand Linux systems. Joshua's expertise covers a range of Linux distributions, including Ubuntu, Fedora, Debian, RHEL, openSUSE, and Arch Linux. His passion is helping users new to Linux or Unix-like systems learn from his knowledge.

Follow me

Latest posts by Joshua James (see all)

  • How to Install BleachBit on Ubuntu 24.04/22.04/20.04 - Tuesday, July 9, 2024
  • How to Remove Packages From Ubuntu via Command-Line - Tuesday, July 9, 2024
  • How to Install RetroArch on Ubuntu 24.04/22.04/20.04 - Tuesday, July 9, 2024

You may also like:

  1. How to Install GitHub Desktop on Ubuntu 24.04, 22.04 or 20.04
  2. How to Install 7-Zip on Ubuntu 24.04, 22.04 or 20.04
  3. How to Install Memcached on Ubuntu 24.04, 22.04, or 20.04
  4. How to Install ImageMagick on Ubuntu 24.04, 22.04, or 20.04
  5. How to Install CMake on Ubuntu 24.04, 22.04 or 20.04
  6. How to Install UNRAR on Ubuntu 24.04, 22.04 or 20.04
  7. How to Install OBS Studio on Ubuntu 24.04, 22.04 or 20.04
  8. How to Install Nvidia Drivers on Ubuntu 24.04, 22.04, or 20.04
  9. How to Install PostgreSQL 16 on Ubuntu 24.04, 22.04, or 20.04
  10. How to Install on Ubuntu 24.04, 22.04, or 20.04
How to Install zlib on Ubuntu 24.04, 22.04, or 20.04 - LinuxCapable (2024)
Top Articles
Latest Posts
Article information

Author: Kimberely Baumbach CPA

Last Updated:

Views: 6486

Rating: 4 / 5 (61 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Kimberely Baumbach CPA

Birthday: 1996-01-14

Address: 8381 Boyce Course, Imeldachester, ND 74681

Phone: +3571286597580

Job: Product Banking Analyst

Hobby: Cosplaying, Inline skating, Amateur radio, Baton twirling, Mountaineering, Flying, Archery

Introduction: My name is Kimberely Baumbach CPA, I am a gorgeous, bright, charming, encouraging, zealous, lively, good person who loves writing and wants to share my knowledge and understanding with you.