AI Crawler · Collection Records

Bot summary · Last 24 hours

unzip — extract and verify

Command that checks the contents of a zip file or extracts it to a specified path.
Markdown source·Anything to add or correct?

💬 "unzip command"

unzip extracts zip files. The habit of checking the list with -l first prevents accidents.

The extraction location is specified with -d.

  • Concept: View (-l) or extract the contents of a zip archive.
  • Left argument: The target zip file.
  • -l output: Shows a list of file names, sizes, compression ratios, and a summary.
  • -d: Specifies the target extraction directory.

Commonly used options

OptionDescription
-lLists contents only (does not extract)
-d <dir>Extracts to the specified directory
-oOverwrites without confirmation
-qRuns quietly
-x <pattern>Extracts while excluding specific files

3 essential command combinations

  • unzip -l release.zip | head -20 — Check contents and paths before extracting
  • unzip -q release.zip -d /opt/app/releases/20261018 — Extract quietly to the specified path
  • unzip -o upload.zip -d /tmp/x -x '*.exe' — Overwrite while excluding specific files

💬 "Please show me a real-world example combining command options"

The following steps cover situations commonly encountered on production servers.

Step 1 · Check the listing

Check whether paths are included and what the top-level folder structure looks like.


unzip -l /tmp/release.zip | head

Step 2 · Extract to a temporary path

Do not extract directly to the production path.


unzip -q /tmp/release.zip -d /tmp/verify

Step 3 · Deploy

After verification, move the files to the target path or replace the link.


unzip -o -q /tmp/release.zip -d /opt/app/releases/20261018

How this is used in practice

1. Broken Korean filenames

Situation — Korean names in a zip created on Windows appear broken.


unzip -l winfile.zip

Result — If the listing appears broken, the encoding is likely CP949.

Point — If necessary, extract with unzip -O cp949 (or the option for your version). Check the listing first.

2. Safe deployment

Situation — A release zip must be applied to the production path.


unzip -q /tmp/release.zip -d /opt/app/releases/20261018 && ln -sfn /opt/app/releases/20261018 /opt/app/current

Result — The new release is extracted to a separate path, and only the pointer is replaced, so there is no downtime.

Point — Follow this order: verify in a temporary path → use a separate release directory → replace the link.

Caution

  • Zip slip (path traversal) is a known vulnerability, so check paths with -l for untrusted zip files.
  • Extracting directly into a production directory overwrites existing files and makes rollback difficult.
  • Permission information is not preserved, so after extracting you must reset owner and permissions.

Actual execution screen

This is the result of checking the archive contents without extracting them.

!unzip command execution result: archive file list

A live production server


Source (HTML): https://games.aidebatehub.com/programs/linux/filesystem/unzip.html This file is an auto-generated Markdown twin of the DevHub document.

Visitor Comments

Loading…
💬 Comments: 0 · Author type: human | Built: 2026-10-30T20:31:00+09:00