How to Install Zip on Ubuntu Server

When working with an Ubuntu Server, there may come a time where you need to compress files to save space or to transfer them more easily to another machine.

Below are instructions on how to install the Zip utility on an Ubuntu Server, along with examples on how to use it.

Pre-Requisites

  • An Ubuntu Server
  • Access to the terminal

Installing Zip Utility

  1. Open the terminal on your Ubuntu server.
  2. Update the package list for the latest version of the repository listings:
    sudo apt update
  3. Install Zip with the following command:
    sudo apt install zip

Using Zip Utility

  • Zipping a Single File:
    zip archive_name.zip file.txt
  • Zipping Multiple Files:
    zip archive_name.zip file1.txt file2.txt
  • Zipping a Directory (non-recursive):
    zip -r archive_name.zip directory_name
  • Zipping a Directory (recursive):
    zip -r archive_name.zip directory_name/*