Packen und Entpacken (Linux): Unterschied zwischen den Versionen
Matt (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „== Packen == tar -zcvf archive-name.tar.gz directory-name Unlike <code>zip</code>, <code>gzip</code> functions as a compression algorithm ''only''. Bec…“) |
Matt (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
||
Zeile 26: | Zeile 26: | ||
tar -xvJf foo.tar.xz | tar -xvJf foo.tar.xz | ||
bunzip2 foo.tar.bz2 | bunzip2 foo.tar.bz2 | ||
[[Kategorie:Linux]] | |||
[[Kategorie:Terminal]] |
Version vom 13. August 2017, 11:42 Uhr
Packen
tar -zcvf archive-name.tar.gz directory-name
Unlike zip
, gzip
functions as a compression algorithm only.
Because of various reasons some of which hearken back to the era of tape drives, Unix uses a program named tar
to archive data, which can then be compressed with a compression program like gzip
, bzip2
, 7zip
, etc.
In order to "zip" a directory, the correct command would be
tar -zcvf archive.tar.gz directory/
This will tell tar
to c (create) an archive from the files in directory
(tar
is recursive by default), compress it using the z (gzip) algorithm, store the output as a f (file) named archive.tar.gz
, and v(verbosely) list (on /dev/stderr so it doesn't affect piped commands) all the files it adds to the archive.
The tar
command offers gzip
support (via the -z
flag) purely for your convenience. The gzip
command/lib is completely separate. The command above is effectively the same as
tar -cv directory | gzip > archive.tar.gz
To decompress and unpack the archive into the current directory you would use
tar -zxvf archive.tar.gz
That command is effectively the same as
gunzip < archive.tar.gz | tar -xv
tar
has many, many, MANY other options and uses as well; I heartily recommend reading through its manpage sometime.
Entpacken
tar xfv foo.tar.gz tar -xjf foo.tar.bz2 tar -xvJf foo.tar.xy tar -xvJf foo.tar.xz bunzip2 foo.tar.bz2