Create a .zip or .tar.gz archive in Ubuntu Linux (command line)

With Gnome, this is as easy as opening a file browser > select file(s) > right click > Compress…

Here are the simple cases for the command line.  For many more advanced options, check the man pages for zip and tar.

zip -r /path/of/files/to/compress/

tar -zcvf my_archive.tar.gz /path/of/files/to/compress/

…and to uncompress an archive on the command line:


tar -xvf my_archive.tar.gz

I know this is really basic stuff, right?  Perhaps now that I’ve blogged it I won’t forget again.

Stefan Pejcic
Join the discussion

I enjoy constructive responses and professional comments to my posts, and invite anyone to comment or link to my site.