Skip to content

Instantly share code, notes, and snippets.

@frhan
Last active December 6, 2022 23:47
Show Gist options
  • Save frhan/b8e929157fd463046eb83b4e1584516c to your computer and use it in GitHub Desktop.
Save frhan/b8e929157fd463046eb83b4e1584516c to your computer and use it in GitHub Desktop.
How to create tar.gz file in Linux using command line

create tar.gz file in Linux

tar -czvf file.tar.gz directory

Verification

$ tar -ztvf projects.tar.gz

extract a tar.gz compressed archive on Linux

$ tar -xvf file.tar.gz
$ tar -xzvf file.tar.gz
$ tar -xzvf projects.tar.gz

Getting help

$ tar --help

tar command options

-c Create a new archive
-x Extract files from an archive
-t List the contents of an archive
-v Verbose output
-f file.tar.gz Use archive file
-C DIR Change to DIR before performing any operations
-z Filter the archive through gzip i.e. compress or decompress archive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment