Linux Tar Command Guide
Introduction
Tar is a command-line utility used to create and manipulate archive files. It is commonly used for compressing and packaging files.
Usage
To create an archive, use the following command:
tar [options] [archive-file] [file-or-directory]
Common Options
-c
: Create a new archive.-x
: Extract files from an archive.-v
: Verbosely list files processed.-f
: Specify the archive file name.-z
: Compress the archive using gzip.
Examples
-
Create a new archive:
tar -cvf archive.tar /path/to/directory
-
Extract an archive:
tar -xvf archive.tar
-
Create a compressed archive:
tar -czvf archive.tar.gz /path/to/directory
-
Extract a compressed archive:
tar -xzvf archive.tar.gz