To create a tar.gz
file in Linux using the command line, you can use the tar
command with the gzip
option.
Here is an example of how to create a tar.gz
file called archive.tar.gz
that includes the dir1
and dir2
directories:
tar -czvf archive.tar.gz dir1 dir2
The c
option specifies that the tar
command should create a new archive. The z
option tells tar
to compress the archive using gzip
. The v
option enables verbose output, which will display the names of the files being added to the archive. The f
option specifies the name of the archive file.
You can also use the tar
command to create a tar.gz
archive of a single file. For example:
tar -czvf archive.tar.gz file.txt