Create archives
To create a tar.gz
archive from a given folder we can use the following command:
$ tar -zcvf <archive-name>.tar.gz <source-folder-name>
The command compresses the content of the source folder and creates an archive file named <archive-name>.tar.gz
.
Example:
Extract archives
To extract a tar.gz archive let’s use the following command:
$ tar -xvzf <tar-archive-name>.tar.gz
The command extracts the archive to the folder <tar-archive-name>
.
Example:
Note, that to preserve file permissions we need to add -p
option. For example:
$ tar -pzcvf <archive-name>.tar.gz <source-folder-name>
and
$ tar -pxzvf <tar-archive-name>.tar.gz