cli-tarHow do I create a tar.gz file using the command line?
Creating a tar.gz file using the command line is a simple process. The tar command can be used to create a tar file, and the gzip command can be used to compress the tar file. This can be done in one step with the -z flag.
The following example command creates a tar.gz file from the my-directory directory:
tar -zcvf my-directory.tar.gz my-directory
The -z flag tells tar to compress the tar file using gzip. The -c flag creates a new tar file, the -v flag enables verbose output, and the -f flag specifies the file name for the tar file.
The output of the command should look like this:
tar: Removing leading `/' from member names
my-directory/
my-directory/file1.txt
my-directory/file2.txt
my-directory/file3.txt
The my-directory.tar.gz file will now be created in the current directory.
Parts of the command:
tar: The command used to create tar files-z: Flag to telltarto compress the tar file usinggzip-c: Flag to create a new tar file-v: Flag to enable verbose output-f: Flag to specify the file name for the tar file
Helpful links
More of Cli Tar
- How do I use the command line to create a tar file?
- How do I use the tar command on Windows?
- How do I use the command line to tar and zip a file?
- How do I use the Unix tar xzvf command?
- How do I use tar gzip with a password?
- How do I use the Unix tar xvf command to extract files?
- How to use tar shell to integrate with Vipps?
- How do I use gzip and tar in Linux?
- How do I compress a file using gzip and tar.xz?
- How do I use the command line to tar and zip files?
See more codes...