9951 explained code solutions for 126 technologies

cli-tarHow do I tar gzip a directory?

To tar gzip a directory, use the tar command with -z and -c flags.

tar -zcvf <name_of_archive>.tar.gz <name_of_directory>

This will create a tar.gz archive with the contents of the specified directory.

The flags used are:

  • -z: Compress the resulting archive with gzip.
  • -c: Create a new archive.
  • -v: Verbosely list files which are processed.
  • -f: Specify the filename of the archive.

Helpful links

Edit this code on GitHub