You can create a .tar.gz file in Linux using the tar command. The basic syntax is as follows:
tar -czvf file_name.tar.gz directory_to_compress
Here’s what each option does:
c: Create a new archive.z: Compress the archive using gzip.v: Display verbose output, showing the progress of the compression process.f: Specify the filename of the archive to be created.
For example, if you want to create a .tar.gz archive of the directory /home/user/documents, you would run the following command:
tar -czvf documents.tar.gz /home/user/documents
This will create a new archive called documents.tar.gz that contains all the files and subdirectories within the /home/user/documents directory.