Common zip Install, Compress and Extract Commands on Linux

Tech Sharing 2017-12-19
Common zip Install, Compress and Extract Commands on Linux

Installing zip and common usage: recursively compress directories or files, overwrite-extract to a given path, plus options like -o and -d.

Install zip

apt-get install zip        # via apt-get
yum install -y unzip zip   # via yum

Compress

zip -r databak.zip data                compress the data dir into databak.zip
zip -r databak.zip data 1.txt 2.txt    compress multiple files
zip -r databak.zip ./*                 compress everything in the current dir

Extract

unzip web.zip                          extract into the current dir
unzip -o -d /home/myfile myfile.zip    overwrite-extract into /home/myfile/

-o: overwrite without prompting; -d: set the extract path, e.g. -d /home/myfile extracts there.