AI Crawler · Collection Records

Bot summary · Last 24 hours

zip — Create Compressed Archive

A command that bundles multiple files into a zip archive. Especially useful when exchanging files with Windows.
Markdown source·Anything to add or correct?

💬 "zip command"

zip is an archive format that opens directly on Windows too. It is especially convenient for transferring files between Linux and Windows.

When including directories, you must add -r.

  • Concept: bundles files and directories into zip format.
  • Left argument: the name of the archive file to create.
  • Right argument: the list of files/directories to compress.
  • Progress display: by default, prints the compression ratio for each file.

Commonly used options

OptionDescription
-rrecursively include directories — required
-qrun quietly without progress output
-x '*.log'exclude specific patterns
-eencrypt with a password
-9compress with maximum compression ratio

Three essential command combinations

  • zip -r site-20261018.zip /var/www/html — bundle the web root into a zip
  • zip -rq release.zip . -x '.log' -x 'cache/' — bundle quietly, excluding logs and cache
  • zip -r9 arch.zip src/ docs/ README.md — bundle artifacts with maximum compression

💬 "How would you use it in an automation script?"

Here are common production server situations, organized in order.

Step 1 · Identify what to archive

Move to the target directory or specify an absolute path.


cd /var/www && ls html

Step 2 · Compress

Use the recursive option to archive and specify exclusion patterns.


zip -rq /tmp/site-20261018.zip html -x '*.log'

Step 3 · Verify

Check the listing and integrity.


unzip -l /tmp/site-20261018.zip | tail -2

In practice, use it like this

1. Delivering to a Windows user

Situation — the client company cannot open Linux archives (tgz), so zip is needed.


zip -r delivery-20261018.zip report/ data.xlsx

Result — it creates a zip that can be opened directly on Windows.

Point — Korean filenames can cause encoding issues, so check whether to use the default instead of -UN=UTF8.

2. Partial backup

Situation — you want to back up only the uploads folder as zip.


zip -rq /backup/uploads-20261018.zip /var/www/html/uploads

Result — an archive containing only upload files is created.

Point — for large amounts of data, tar+gzip is often faster. Use zip only when you need compatibility.

Caution

  • If you omit -r, the directory is stored empty (the most common mistake).
  • zip does not fully preserve permission/owner information. Use tar for server recovery.
  • Encryption (-e) can be weak, so use a separate encryption tool for sensitive information.

Actual output

This is the result of checking the archive file list and size.

!zip command execution result: archive file list and size

Production server


Source (HTML): https://games.aidebatehub.com/programs/linux/filesystem/zip.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