How to Unzip a Directory Using Ubuntu Server Terminal

Using ZIP’ed directories is often necessary when transferring files from one computer to another, or when restoring backups.

This guide shows how to unzip directories using the terminal on your Ubuntu server, and covers various options for handling file conflicts.


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

Unzipping a Directory

  1. Open the terminal on your Ubuntu server.
  2. Navigate to the directory containing the zip file you wish to extract.
  • Use the cd command to change directories. E.g., cd /path/to/directory.
  1. Run the following command to unzip the archive.

Handling File Conflicts

When unzipping an archive, you might encounter situations where files within the zip archive have the same names as files in the destination directory. The unzip command provides several options to handle such conflicts:

  • Overwriting existing files without prompting:
    unzip -o
  • Renaming files automatically to avoid overwriting:
    unzip -B
  • Prompting for action on each conflict:
    unzip -n

Advanced Unzipping Options

  • Extracting to a different directory:
    unzip -d /path/to/destination
  • Listing the contents of a zip file without extracting:
    unzip -l
  • Excluding specific files or patterns:
    unzip -x filename_to_exclude.ext
  • Extracting only specific files or patterns:
    unzip filename_to_extract.ext
  • Overwriting newer files:
    unzip -o -DD