Le format de fichier d'archive compressé le plus courant sous Linux est le format tar.gz. Le fichier tar est un format de fichier d'archive. Tar.gz est un fichier tar compressé.
Créer des archives tar.gz
La commande tar peut être utilisée pour créer des archives tar.gz.
tar czf new-tar-file-name.tar.gz file-or-folder-to-archive
Voici l'explication de la commande :
c - create new archive. z - compress the archive using gzip. f - use archive file. new-tar-file-name.tar.gz - the name of the tar.gz to create. file-or-folder-to-archive - the name of the folder we want to archive.
Ajout de plusieurs répertoires
tar -czf new-tar-file-name.tar.gz file1 file2 folder1 folder2
Extraire les archives tar
archives gz
tar -xzf tar-file-name.tar.gz
Voici l'explication de la commande :
x - extract the archive. z - uncompress the archive using gzip. f - use archive file. tar-file-name.tar.gz - the name of the tar.gz to create.
La commande tar extraira tous les fichiers/dossiers de l'archive dans le répertoire courant. Pour extraire vers un emplacement spécifique, modifiez la commande comme suit
tar -xzf tar-file-name.tar.gz /path/to/location
archives bz2
L'extraction de tar.bz2 (fichier bzip2) est très similaire à la façon dont vous extrayez le fichier tar.gz. Au lieu d'utiliser l'indicateur -z, vous devez utiliser l'indicateur -j pour le format bzip2
tar -xvjf tar-file-name.tar.gz
Voici l'explication de la commande :
x - extract the archive. v - verbose. show information as files are being extracted. j - filter the archive through bzip2 f - use archive file. tar-file-name.tar.gz - the name of the tar.gz to create.
La commande tar extraira tous les fichiers/dossiers de l'archive dans le répertoire actuel.