Skip to main content

How To: Unter Linux Archive erstellen (tar, xz, zip, etc...)

Verzeichnisse unter Linux komprimieren und entpacken

Tar

Tar directory

Keine Kompression
tar -v -c -f new_archive.tar /path/to/directory
xz Kompression
  • gute Kompressionsrate
  • lange Kompressionsdauer
  • multithreaded

-9 = xz verwendet die höchste Kompressionsstufe
-T0 = xz verwendet alle zur Verfügung stehenden CPU Threads
--memory=70% = xz verwendet maximal 70% des zur Verfügung stehenden Arbeitsspeichers (Kompressionsrate wird ggf. schlechter, jedoch werden Out-of-Memory Fehler verhindert)

tar -v -c -I 'xz -T0 -9 --memory=70%' -f new_archive.tar.xz /path/to/directory
zstd Kompression
  • normale Kompressionsrate
  • kurze Kompressionsdauer
  • multithreaded

-T0 = zstd verwendet alle zur Verfügung stehenden CPU Threads

tar -v -c -I 'zstd -T0' -f new_archive.tar.zstd /path/to/directory
gzip Kompression
  • normale Kompressionsrate
  • lange Kompressionsdauer
  • nicht multithreaded

-9 = gzip verwendet die höchste Kompressionsstufe

tar -v -c -I 'gzip -9' -f new_archive.tar.gz /path/to/directory

Untar directory

Erkennt automatisch das verwendete Format

tar -vxf /path/to/archive.tar.xz

List tar contents

Erkennt automatisch das verwendete Format

tar -vtf /path/to/archive.tar

Extract only one file from tar

Erkennt automatisch das verwendete Format

tar -vxf /path/to/archive.tar.xz in/archive/file.txt

Zip

Zip directory

zip -v -r new_archive.zip /path/to/directory

Unzip archive

unzip -v /path/to/archive.zip

List zip Content

unzip -l /path/to/archive.zip

Extract only one file from zip

unzip -v /path/to/archive.zip in/archive/file.txt