# How to use the SSH zip command

> Canonical: https://jethost.com/kb/how-to-use-the-ssh-zip-command/ · Last modified: 2026-08-20T06:50:06+00:00

The SSH zip command creates and the `unzip` command extracts .zip archives on Linux. In particular, zip is widely used because .zip files work on Windows, Mac, and Linux. Furthermore, zip lets you archive single files, multiple files, or entire directories, and you can exclude certain files from the archive. Use zip via SSH for backups, downloads, or transferring website files on your hosting account.

## Archive single or multiple files

To create a zip archive of specific files:

```
zip archive.zip file1.txt
```

For multiple files:

```
zip archive.zip file1.txt file2.txt file3.txt
```

The archive name comes first, then the files to include. You can use wildcards: `zip backup.zip *.php` to zip all PHP files in the current directory.

## Archive an entire directory

To include a directory and all its contents recursively, use `-r`:

```
zip -r archive.zip /path/to/directory
```

Example: `zip -r wordpress-backup.zip public_html/` creates a zip of your website files. Run from your home directory so the path is correct.

## Exclude files when archiving

Use `-x` to exclude files from the archive. To exclude a single file:

```
zip -r archive.zip /path/to/directory -x fileToExclude
```

To exclude all files of a given type (e.g. all .log files):

```
zip -r archive.zip /path/to/directory -x "*.log"
```

You can add multiple exclusions: `-x "*.log" -x "*.tmp" -x "cache/*"`. Useful when backing up WordPress but excluding cache or log folders.

## Extract a zip file

To unzip an archive into the current directory:

```
unzip archive.zip
```

Extract to a specific directory:

```
unzip archive.zip -d /path/to/destination
```

To list contents without extracting: `unzip -l archive.zip`.

## Zip vs tar

Zip archives are common for downloads and cross-platform use. For Linux-only backups, `tar.gz` often gives better compression. See our guide on the [SSH tar command](https://jethost.com/kb/how-to-use-the-ssh-tar-command/) for gzip archives.

## Common use cases

Typical uses for SSH zip command on a [Linux hosting](https://jethost.com/web-hosting/) account:

- Creating backups of website files for download or transfer
- Bundling logs or exports before sending to support
- Archiving uploads or media folders while excluding cache
- Preparing files for download by visitors (zip is widely supported)

## Need more help?

Explore more SSH and hosting guides in our [knowledgebase](https://jethost.com/help/). JetHost [web hosting](https://jethost.com/web-hosting/) includes SSH access for managing your server and creating archives.
