tar -zcvf filename.tar.gz /path/to/dir
tar -zxvf filename.tar.gz -C /tmp

Source: http://www.cyberciti.biz/faq/how-do-i-compress-a-whole-linux-or-unix-directory/