The tar command is used to create, maintain, modify, or extract files from an archive file. It stands for "tape archive" and is commonly used to combine multiple files into a single file for easier storage or transfer. The tar command can also compress the archive using various compression methods, such as gzip or bzip2.
Here are some common usages of the tar command:
-
Create an archive:
tar -cf archive.tar /path/to/directory -
Extract an archive:
tar -xf archive.tar -
List contents of an archive:
tar -tf archive.tar -
Create a compressed archive with gzip:
tar -czf archive.tar.gz /path/to/directory -
Create a compressed archive with bzip2:
tar -cjf archive.tar.bz2 /path/to/directory
The options used with tar can vary based on the desired operation, such as c for create, x for extract, t for list, z for gzip compression, and j for bzip2 compression.
