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 telltar
to 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 gzip, tar, and zip to compress files?
- How do I use the command line to tar and zip a file?
- How do I use the command line to tar and zip files?
- How do I use the Unix tar zip command?
- How do I create a tar.zip file in Unix?
- How do I use the command line to tar and zip a file?
- How do I use the command line to tar and zip a file?
- How do I use the command line to tar and distribute files?
- How do I use the Unix tar xvf command to extract files?
- How do I use the shell to tar and zip files?
See more codes...