↑ ↓ select, Enter open, Esc close

Pack a directory into a ZIP archive

Caution: This command changes the system. Understand what it does before you run it.

Adjust the values, the command updates live
user@server
cd /var/www/vhosts/example.com && zip -rq /var/www/vhosts/example.com/private/httpdocs.zip httpdocs

Changes into the parent folder and packs the directory recursively (-r) without listing files (-q). Thanks to the change of directory, the archive contains relative paths like httpdocs/index.php instead of the full server path.

Note: For backups on Linux, tar is usually better because it fully keeps permissions and owners. ZIP is the better choice for recipients on Windows or macOS.

Also searched as

  • zip a folder in linux
  • create a zip file
  • download a website as zip
  • compress a directory to zip

Related one-liners

All in Filesystem

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.