- gzip program can compress the single file
- tar program can create the single file from multiple files or folders
- if you want to pack and compress the directory, you need both of them
Creating archive
tar -zcvf archive.tgz path/to/src/dir/
Gzip is suitable for packing the single files only:
gzip archivefile1.txt # creates the archive and deletes the source file gzip -c archivefile1.txt > archivefile1.txt.gz # creates the archive and preserves the source file gzip -r documents_folder # creates separate archives from all files recursively (obviously NOT what you want with your directory!:))
Extracting from archive
tar -zxvf archive.tgz
Or with gunzip:
gunzip archive.tgz
Lists all files in the archive
tar -ztvf archive.tgz
Parameters:
z - gzip type
x - extract the archive
c - create the archive
v - verbose
f - user archive file (= not stdin/stdout)
t - list files in archive