--- title: unzip โ€” extract and verify date: 2026-10-18 time: 12:00 model: admin category: programs author_type: human summary: Command that checks the contents of a zip file or extracts it to a specified path. tags: program, File and disk management, unzip --- **๐Ÿ’ฌ "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 | Option | Description | | --- | --- | | -l | Lists contents only (does not extract) | | -d | Extracts to the specified directory | | -o | Overwrites without confirmation | | -q | Runs quietly | | -x | 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](https://games.aidebatehub.com/assets/unzip-demo.png) 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.