zip
an archive everyone can openzip creates the archive format every desktop system understands without extra software. Unlike tar it compresses each file separately and does not preserve Linux ownership, so it is for sharing rather than for backups.
tar.gz between Linux machines; zip when the other end is Windows or macOS.
At the terminal
Read the session first, then the notes: each numbered line in the output is answered by the note with the same number.
What the numbered lines are telling you
A directory has no contents of its own, so there is nothing to shrink: 0%.
index.html became 63% smaller. Text compresses well; photos and video, already compressed, barely change.
The password is not shown as it is typed. It is asked twice to catch a mistake.
Encryption protects the contents only. Anyone can list the archive and see that it holds passwords.txt.
Switches
A switch changes how the command behaves. These are the ones used day to day; man zip lists the rest. Single-letter switches can usually be joined, so -l -a may be written -la.
-r- Recursive: include a directory and everything inside it.
-e- Encrypt: ask for a password.
-u- Update: add only files that are new or changed.
-d- Delete entries from an existing archive.
-x PATTERN- Exclude files matching the pattern.
-9- Best compression. -1 is fastest; -0 stores without compressing.
-q- Quiet: do not list each file.
Variations worth knowing
The same tool, pointed at a narrower question. These four cover most of what it is reached for day to day.
zip -r project.zip project -x "*.git*"Leaves out everything matching a pattern.
zip -u site.zip site/index.htmlUpdates one file inside an existing archive.
zip -9 -r small.zip docs/Uses the strongest compression, at the cost of time.
zip -d site.zip "site/old.html"Deletes an entry from the archive.
In cybersecurity
The password option is weaker than it looks.
The default scheme used by -e can be cracked quickly. For anything sensitive use 7z with AES, or encrypt the file with gpg or age.
-P password leaves it in your shell history and visible to other users in the process list. Use -e and type it.
A zip does not record Linux owners, and may not keep permissions. Restoring a system from one will not give back what you had.