

The following example shows how to create an archive named “web_” of the /var//var/www/website By default, directories are archived recursively unless -no-recursion option is specified. You can create tar.gz files from the contents of one or more directories or files. If you want to create the tar.gz in a specific directory, provide a full path to the archive file: tar -czf /home/user/ file1 file2 Use the -v option to make the tar command more visible and print the names of the files being added to the archive on the terminal. To verify that the archive is created, list the directory contents with ls

On success, the command doesn’t print any output. The user running the command must have write permissions on the directory where the tar.gz file will be created, and read permissions on the files being added.įor example, to create an archive named “” from “file1” and “file2” you would use the following command: tar -czf file1 file2 a space-separated list of files and directories to be added to the archive. -z - sets the compression method to gzip.-c - instructs tar to create a new archive.The general form of the command for creating tar.gz files is as follows: tar -czf file-name. Most Linux distributions come include the GNU version of tar that supports compressing archives. This article describes how to create tar.gz files. The command can also compress archives using a vast range of compression programs with gzip is the most popular algorithm.īy convention, the name of a tar archive compressed with gzip should end with either. In Linux operating systems, you can use the tar command to create tar archives. A tar archive is a file that stores a collection of other files, including information about them, such as the ownership, permissions, and timestamp.
