Often, Unix/BSD/Linux files and source code are distributed in a zipped tar file, sometimes called a tarball. Extensions for tarballs are usually .tgz or .tar.gz (gz because it was compressed using gzip, the free GNU zip program). Rarely, you may run across a tar file that is not compressed and has an extension of simply .tar.
Here are some common uses for tar. If you pass a directory or a wildcard to tar, it will include all subdirectories in the tar file by default.
Create a gzipped tar archivetar czvf backup.tgz files-to-backup
Create a gzipped tar archive, preserving file permissions
tar czvpf backup.tgz files-to-backup
Extract a gzipped tar archive
tar xzvf backup.tgz files-to-backup
Create a bzipped tar archive (using bzip compression instead of gzip)
tar cjvf backup.bz2 files-to-backup
Extract a bzipped tar archive
tar xjvf backup.bz2 files-to-backup
List files in a tar archive without extracing
tar tf backup.tgz
List files in a zipped tar archive without extracing
tar tzf backup.tgz