commands
tar — bundle and restore files
GNU tar creates, lists or extracts archives; -z selects gzip, -C changes directory. List before extracting trusted archives into an empty private directory. Successful status does not establish safety. Example assumes a fresh archive lab fixture with new output names.
Formal Syntax & Structure
linux syntaxlinux
tar -{c|t|x}[z]f ARCHIVE [-C DIRECTORY] [MEMBER...]Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| -c | option | create |
| -t | option | list |
| -x | option | extract |
| -z | option | gzip |
| -f | option | Takes an archive filename or - for the relevant standard stream. |
| -C | option | Takes a directory; changes the working directory for subsequent operands. |
| MEMBER | operand | Input path(s) for creation; optional selection of archived members for listing or extraction. Supply explicit input paths when creating. |
| ARCHIVE | operand | New archive path for creation or existing trusted archive for listing/extraction. |
Return Value
exit status and output
GNU tar creates, lists or extracts archives; -z selects gzip, -C changes directory. List before extracting trusted archives into an empty private directory. Successful status does not establish safety.
Working Example
Example Snippetlinux
tar -cf notes.tar notes.txt report.txttar -tf notes.tar