← Linux and the Command Line Lesson 33 of 51 · 5 XP

zip and unzip

Theory

Machine translation, not yet reviewed by a native speaker.

zip is the format Windows users are used to. .zip archives open everywhere without extra programs, which makes them handy for sending to people.

zip archive.zip file1.txt file2.txt     # pack files
zip -r site.zip site/                   # a whole folder (-r is a must!)
zip -e secret.zip passwords.txt         # with a password (the encryption is weak)

unzip archive.zip                       # unpack here
unzip archive.zip -d out/               # into the folder out
unzip -l archive.zip                    # see the contents

How zip differs from tar.gz:

zip tar.gz
where it's common Windows, sending to people Linux, backups, source code
compression each file separately the whole archive at once (usually stronger)
Linux permissions and owners partly lost kept
getting one file out fast the archive has to be read up to it

Our mini Linux has only unzip and gzip. You can install zip in Debian or Kali with sudo apt install zip.

Single files are compressed like this:

gzip big.log            # replaces it with big.log.gz
gunzip big.log.gz       # back again
zcat big.log.gz | grep ERROR    # read a compressed file without unpacking it

Sign up for free to mark finished lessons and track your progress.