How do I compress (tar, zip) a whole directory from the Ubuntu command line?
The simplest approach is to use the tar command as follows (syntax of tar command):
$ tar -zcvf archive-name.tar.gz directory-name
-z : Compress archive using gzip program
-c: Create archive
-v: Verbose i.e display progress while creating archive
-f: Archive File name
For example, say you have a directory called /home/jerry/prog and you would like to compress this directory then you can type tar command as follows:
$ tar -zcvf prog-1-jan-2005.tar.gz /home/jerry/prog
If you would like to use Zip, you’ll need to install it first if that has not been done already.
$ sudo apt-get update
$ sudo apt-get install zip
$ zip --help to quickly pull up the list of commands.