This post includes my notes about how to compress and pack files and folders using the command line commonly in the terminal on Unix/Linux/MacOS.

.zip

To compress

$ zip -r filename.zip dirname

To extract

$ unzip filename.zip

.tar

To pack

$ tar cvf filename.tar dirname

To unpack

$ tar xvf filename.tar

.gz

To compress

$ gzip filename

To extract

$ gunzip filename.gz

.tar.gz

To compress

$ tar zcvf filename.tar.gz dirname

To extract

$ tar zxvf filename.tar.gz