tar
ArchivesFundamentals In simulator In real LinuxCreate and extract archives
Name: tar = tape archive
You can practise it right away in the simulator, and use it in real Linux mode too.
Description
tar bundles files and directories into a single archive (.tar), keeping structure, permissions and times. It doesn't compress by itself but can call gzip (-z), bzip2 (-j) or xz (-J) to make .tar.gz, .tar.bz2 or .tar.xz files.
Remember: c = create, x = extract, t = list, with the archive name right after f.
Syntax
tar [OPTION]... [FILE]...Common options
| -c / -x | Create / extract |
| -t | List the contents |
| -f ARCHIVE | Archive file name (almost always needed) |
| -z / -j / -J | Compress with gzip / bzip2 / xz |
| -a / --auto-compress | Pick the compression from the file extension (.tar.gz, .tar.xz, …) |
| -v | Verbose |
| -C DIR | Extract into a directory |
| --exclude PATTERN | Leave out files matching PATTERN, e.g. --exclude="*.log" |
| -T / --files-from FILE | Read the names to archive from FILE |
| -r / --append | Add files to an existing (uncompressed) archive |
| -p / --preserve-permissions | Keep the permissions when extracting |
| -k / --keep-old-files | Do not overwrite existing files when extracting |
| --strip-components N | Drop the first N directories from names when extracting |
| -O / --to-stdout | Extract files to standard output (no files written) |