cli-tarHow do I create a .tar.gz file using the command line?
Creating a .tar.gz
file using the command line is a two-step process. First, you must create a .tar
file, and then compress the .tar
file into a .tar.gz
file.
To create a .tar
file, use the command tar -cvf filename.tar file1 file2 file3
:
$ tar -cvf myfiles.tar file1 file2 file3
file1
file2
file3
This command will create a .tar
file named myfiles.tar
containing the files file1
, file2
, and file3
.
To compress the .tar
file into a .tar.gz
file, use the command gzip filename.tar
:
$ gzip myfiles.tar
This will create a .tar.gz
file named myfiles.tar.gz
.
Code explanation
**
tar -cvf filename.tar file1 file2 file3
: Creates a.tar
file namedfilename.tar
containing the filesfile1
,file2
, andfile3
.gzip filename.tar
: Compresses the.tar
file into a.tar.gz
file namedfilename.tar.gz
.
## Helpful links
More of Cli Tar
- How do I use the command line to tar and zip files?
- How can I use tar commands to zip a file?
- How do I use gzip, tar, and zip to compress files?
- How do I use the Unix tar zip command?
- 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 shell to tar and zip files?
- How do I create a tar.zip file in Unix?
- How do I use the command line to tar and distribute files?
- How do I use the command line to create a tar file?
See more codes...