On Ubuntu, install the unzip package, inspect the archive before extracting it, and use a destination directory so an unfamiliar ZIP cannot scatter files across your working tree.
The basic command is short. The useful skill is knowing how to list first, control overwrite behavior, handle odd filenames, and verify that the archive is healthy before it becomes part of a deployment.
Table of contents
- Install unzip and inspect the archive
- Extract into a deliberate destination
- Control overwrite, selection, and exclusions
- Handle permissions, encodings, and large archives
- Use ZIP extraction safely in deployments
- How this fits the rest of the stack
- FAQ
Install unzip and inspect the archive
Ubuntu does not always include the classic unzip utility in minimal images. Install it from the configured package repositories, then list the archive before extracting. Listing shows paths, sizes, and whether the author wrapped everything in a top-level directory. That one preview prevents most cleanup work.
sudo apt update
sudo apt install unzip
unzip -l release.zip
unzip -t release.zip
The test command checks archive integrity without writing files. It cannot prove that the contents are trustworthy, but it catches truncation and common corruption. For downloaded deployment artifacts, verify a published checksum as a separate step. An archive that extracts successfully can still be the wrong artifact.
Extract into a deliberate destination
Use -d to choose a destination instead of assuming the archive has a tidy internal layout. Create a new directory, extract, and inspect permissions before moving anything into its final place. Quoting paths matters when filenames contain spaces or shell characters.
mkdir -p extracted-release
unzip release.zip -d extracted-release
find extracted-release -maxdepth 2 -type f | head
The unzip tool creates directories from paths stored in the archive. Avoid extracting untrusted archives as root, especially into system directories. Work as an ordinary user in a temporary directory, inspect the result, then install only the files the application needs. That keeps an innocent convenience command from becoming a privileged file-write mechanism.
Control overwrite, selection, and exclusions
Interactive overwrite prompts are useful at a terminal but disastrous in automation because a job can wait forever. Choose a policy explicitly: never overwrite with -n, update older files with -u, or overwrite without prompting with -o only when replacement is truly intended. Extract selected paths by adding their archive names after the ZIP file.
unzip -n release.zip -d output
unzip release.zip 'docs/*' -d output
unzip release.zip -x '*.log' '__MACOSX/*' -d output
Patterns are interpreted by unzip, so quote them to stop the shell expanding them against the current directory. Exclusions are convenient for metadata, but they are not a security boundary. If the archive is untrusted, isolate the extraction and review the paths rather than relying on one glob.
Handle permissions, encodings, and large archives
ZIP is portable partly because it does not preserve every Unix filesystem detail consistently. After extraction, check executable bits, ownership, and symbolic-link behavior before deploying. Do not recursively chmod 777 to make an application start; set the smallest permissions required and keep writable data outside the release directory.
Archives created on older systems may display garbled filenames because their filename encoding is ambiguous. Inspect the unzip help and locale, and consider recreating the archive with a modern tool if it is under your control. For very large archives, confirm free disk space for both the compressed and expanded data and extract on the filesystem where the data will live to avoid a second large copy.
Use ZIP extraction safely in deployments
- Verify the checksum or signature
- List and test the archive
- Extract as a non-root user into a new directory
- Validate required files and permissions
- Run application checks against the staged directory
- Switch a symlink or move the release atomically
- Keep the prior release for rollback
Extraction should create a staged release, not modify the live application one file at a time. Atomic promotion makes a failed extraction recoverable and prevents users from seeing a half-old, half-new tree. If deployments arrive frequently, a container image or reproducible build artifact may provide stronger guarantees than mutable ZIP releases.
How this fits the rest of the stack
A ZIP file is only one piece of a deployment path. The RunxBuild hosting calculator shows the service, storage, and bandwidth around that artifact, while the RunxBuild dashboard keeps releases and logs visible.
Useful related references:
- Ubuntu IP Static: Configure a Static IP on Ubuntu with Netplan
- Installation of Docker in Ubuntu: Step-by-Step for 22.04 and 24.04
- How to Install Docker on Ubuntu: 2026 Guide (22.04 and 24.04)
- Services on RunxBuild
FAQ
How do I install unzip on Ubuntu?
Run sudo apt update followed by sudo apt install unzip. Minimal Ubuntu images may not include it by default.
How do I extract a ZIP into a specific folder?
Use unzip archive.zip -d destination. Create a fresh destination first when you do not know the archive layout.
How can I see files without extracting them?
Use unzip -l archive.zip to list contents and unzip -t archive.zip to test integrity.
How do I prevent unzip from overwriting files?
Use the -n option. In automation, always select an explicit overwrite policy so the process cannot wait for interactive input.
Should I run unzip with sudo?
Avoid it for untrusted archives. Extract as an ordinary user into a staging directory, inspect the result, then install required files with controlled permissions.