Differences
This shows you the differences between two versions of the page.
linux_wiki:archive_compress_unpack_and_uncompress_files_using_tar_star_gzip_and_bzip2 [2016/02/29 22:46] billdozor [bzip2] |
linux_wiki:archive_compress_unpack_and_uncompress_files_using_tar_star_gzip_and_bzip2 [2019/05/25 23:50] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Archive Compress Unpack And Uncompress Files Using Tar Star Gzip And Bzip2 ====== | ||
- | |||
- | **General Information** | ||
- | |||
- | About this page/ | ||
- | |||
- | ---- | ||
- | |||
- | ===== tar ===== | ||
- | |||
- | Options | ||
- | * -c => create new archive | ||
- | * -t => list contents of archive | ||
- | * -x => extract files from archive | ||
- | * -z => compress or decompress in gzip (depending upon if -x or -c was also passed) | ||
- | * -v => display files as they are processed | ||
- | * -j => use bzip2 | ||
- | * -r => append/add file to the end of the existing archive | ||
- | * -u => update a file in an existing archive if the source is newer | ||
- | * -f => archive filename | ||
- | * --selinux => include selinux contexts | ||
- | |||
- | Archive and compress (using gzip) the /var/log directory | ||
- | <code bash> | ||
- | tar -cvzf logs.tar.gz /var/log | ||
- | </ | ||
- | |||
- | \\ | ||
- | List contents of archive | ||
- | <code bash> | ||
- | tar -tf logs.tar.gz | ||
- | </ | ||
- | |||
- | \\ | ||
- | Decompress and unpack at the same time to current directory | ||
- | <code bash> | ||
- | tar -zxvf logs.tar.gz | ||
- | </ | ||
- | |||
- | \\ | ||
- | Decompress and unpack at the same time to a different existing directory | ||
- | <code bash> | ||
- | tar -zxvf logs.tar.gz -C / | ||
- | </ | ||
- | |||
- | \\ | ||
- | Add a new file to an existing archive | ||
- | <code bash> | ||
- | tar -rvf logs.tar newlog.log | ||
- | </ | ||
- | |||
- | ---- | ||
- | |||
- | ===== star ===== | ||
- | |||
- | Archive and compress the /var/log directory (name it logs.tar.gz) | ||
- | <code bash> | ||
- | star -cz -f logs.tar.gz /var/log | ||
- | </ | ||
- | |||
- | \\ | ||
- | List archive contents | ||
- | <code bash> | ||
- | star -t -f logs.tar | ||
- | </ | ||
- | |||
- | \\ | ||
- | Decompress, unpack a bzip2 (star auto selects proper decompression type) | ||
- | <code bash> | ||
- | star -x -f logs.tar.bz2 | ||
- | </ | ||
- | |||
- | ---- | ||
- | |||
- | ===== gzip ===== | ||
- | |||
- | Compress an archive | ||
- | <code bash> | ||
- | gzip logs.tar | ||
- | </ | ||
- | |||
- | \\ | ||
- | Decompress an archive | ||
- | <code bash> | ||
- | gzip -d logs.tar.gz | ||
- | OR | ||
- | gunzip logs.tar.gz | ||
- | </ | ||
- | |||
- | \\ | ||
- | Cat a compressed file (useful for rotated logs) | ||
- | <code bash> | ||
- | zcat messages.1.log.gz | ||
- | </ | ||
- | |||
- | ---- | ||
- | |||
- | ===== bzip2 ===== | ||
- | |||
- | Compress an archive | ||
- | <code bash> | ||
- | bzip2 logs.tar | ||
- | </ | ||
- | |||
- | \\ | ||
- | Decompress an archive | ||
- | <code bash> | ||
- | bzip2 -d logs.tar.bz2 | ||
- | OR | ||
- | bunzip2 logs.tar.bz2 | ||
- | </ | ||
- | |||
- | \\ | ||
- | Cat a compressed file (useful for rotated logs) | ||
- | <code bash> | ||
- | bzcat messages.1.log.bz2 | ||
- | </ | ||
- | |||
- | ---- | ||