Tar bundles multiple files into a single archive file, and can optionally compress them in Linux systems.
Compress
To compress a file or directory
tar -cvf archive_file_name.tar <location-to-the-directory-or-file>the options used in the above command are
-cfor creating a new archive-vto show the detailed output of the process.-fto specify the archive file.
to compress the archive using gzip use the option -z so the archive will be a .tar.gz file
tar -cvfz compressed_archive_file_name.tar.gz <location-to-the-directory-or-file>some other gzip (
-z) alternative to compress the archive are *bzip2 (-j) and xz (-J)
Extract
To compress a file or directory
tar -C <location-to-the-directory-where-to-uncompress> -xvf archive_file_name.tarthe options used in the above command are
xExtract files from an archive.-vto show the detailed output of the process.-fto specify the archive file.
List the contents
To see the files in an archive
tar -tvf compressed_file_name.tarFor a compressed archive provide the valid
-zor-jor-Joption
