Linux Commands Helper
💬 Your AI-powered Linux assistant
tar Command - Archive and Extract Files
The tar command is used to archive files and directories, and can also compress and extract archives.
Syntax
tar [options] [archive-file] [file or directory...]
Common Options
-c
: Create a new archive.-x
: Extract files from an archive.-t
: List archive contents.-v
: Verbosely list files processed.-f
: Use archive file.-z
: Compress with gzip.
Examples
tar -cvf archive.tar file1 file2
Create an archive named archive.tar containing file1 and file2.
tar -xvf archive.tar
Extract the contents of archive.tar.
tar -czvf archive.tar.gz dir1
Create a gzip-compressed archive of dir1 named archive.tar.gz.
Notes
- The tar command is widely used for packaging files for backup or distribution.
- Options can be combined (e.g.,
-czvf
).