# tar -czvf mytarfile.tar.gz mydirwhich will tar and compress the directory "mydir" with its contents.
To extract and untar a .tar.gz file in one command, use the following syntax:
# tar -zxvf mytarfile.tar.gzTo extract and untar a .tar.gz file in one command, into a specific directory, use the following syntax:
# tar -zxvf mytarfile.tar.gz -C /data1/mydir