unzip and zip on Linux: Extract and Create Archives from the Terminal

unzip linux command - custom-unzip-featured.png

unzip on Linux is a top search when someone uploads a .zip from Windows and the server only has tar habits. Install the unzip package once, then extract to a chosen directory — never blindly into /.

Broader archives: tar & gzip guide,
find files,
permissions after extract.

Install unzip and zip

On minimal images the command may be missing.

bashDebian/Ubuntu
sudo apt update && sudo apt install -y unzip zip
apt/dnf
install

List and extract

List without extracting; use -d for destination directory.

bashsafe extract
unzip -l archive.zip
mkdir -p ~/unpack && unzip archive.zip -d ~/unpack
unzip
extract

Create a zip archive

Recursive zip is handy before downloading a folder from a server.

bashcreate
zip -r site-backup.zip /var/www/mysite -x '*/cache/*'
zip -r
create

Prefer tar for Linux backups

tar.gz preserves permissions and is the usual choice for server backups; zip wins for Windows interchange.

TipFor huge trees, tar -czf often beats zip on speed and size.
tar vs zip
choice

Quick Reference

  • Extract: unzip file.zip -d ./out
  • List: unzip -l file.zip
  • Create: zip -r out.zip directory/

Related tutorials

Diagrams are original illustrations by Gnome IT Solutions. Tutorial text © Gnome IT Solutions.