tar
This commands compresses several files and directories into a single file.
Syntax
tar [options] destination.tar files
Compact files
tar -cf files.tar /etc/ /var/
Extract files
tar -xf files.tar
Compress with gzip
tar -czf files.tar.gz /etc/ /var/
Note
The order of the options for the tar command is important. This two commands result in different files: -czf and -fzc
Extract with gzip
tar -xzf files.tar.gz
Important options
tar Options | Description |
---|---|
-c |
compact |
-x |
expand |
-f |
write or read from a file |
-z |
compress or decompress with gunzip |
-j |
compress or decompress with bzip2 |
-P |
use absolute routes (relative by default) |
-p |
preserve file permissions from original files |
-r |
add elements to a compacted file |
-t |
show what files are present in the tar file. |