How to compress a directory from the command line

To compress a directory with all its subdirectories use the command:

tar cfvz archive_name.tar.gz --remove-files /source/directory

With the option --remove-files you delete the source directory after being compressed. If you use the option -cvfj you compress the archive with bzip2

To extract an archive use the command:

tar xvfz archive_name.tar.gz

xvfj: to extract a .tar.bz2 archive