Archiving with Tar
Tar files place several files or the contents of a directory or directories in one file. This is a good way to create backups and archives. Usually, tar files end with the .tar extension.
To create a tar file, type:
tar -cvf filename.tar files/directories |
In this example, filename.tar represents the file you are creating and files/directories represents the files or directories you want to put in the new file.
To extract the contents of a tar file, type:tar -xvf foo.tar |
This command does not remove the .tar file, but it places copies of the .tar contents in the current working directory.
The tar command does not compress files automatically. You can compress tar files with:
tar -czvf foo.tar |
Compressed tar files are conventionally given the extension .tgz and are compressed with gzip.
To expand a compressed tar file type:
create:
tar -cvf mystuff.tar mystuff/tar -czvf mystuff.tgz mystuff/
extracting:
tar -xvf mystuff.tartar -xzvf mystuff.tgz
testing/viewing:
tar -tvf mystuff.tartar -tzvf mystuff.tgz
Note that .tgz is the same thing as .tar.gz
Tar "tars up" a bunch of files into one "tar-file"
gzip is compression, but only works on one file, so the entire "tarfile" is compressed.
tar xvf **.tar.tar