How to Zip a Directory Using Ubuntu Server Terminal

When managing files on an Ubuntu Server – sometimes you need to transfer files to another computer – for example performing an adhoc backup before making changes.

The terminal commands below show how to zip a directory on an Ubuntu Server, using two methods:

  • zipping the current directory, and
  • zipping the current directory along with all its subfolders.

Pre-Requisites

  • An Ubuntu Server
  • Access to the terminal
  • zip installed

Zipping Current Directory

  1. Open the terminal on your Ubuntu server.
  2. Navigate to the directory you wish to zip.
  3. Run the following command:
    zip -r archive_name.zip .

Zipping Current Directory and All Subfolders (Recursive)

  1. Open the terminal on your Ubuntu server.
  2. Navigate to the directory you wish to zip.
  3. Run the following command:
    zip -r archive_name.zip ./*