Differences
This shows you the differences between two versions of the page.
linux_wiki:tar [2016/06/12 16:01] billdozor created |
linux_wiki:tar [2019/05/25 23:50] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Tar ====== | ||
- | |||
- | **General Information** | ||
- | |||
- | Tar archiving utility. | ||
- | |||
- | **Checklist** | ||
- | * Distro(s): Any | ||
- | |||
- | ---- | ||
- | |||
- | ====== Tar Options ====== | ||
- | |||
- | 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 | ||
- | |||
- | ====== Tar Examples ====== | ||
- | |||
- | 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 | ||
- | </ | ||
- | |||
- | ---- | ||