The tar
command in Linux is used to create, extract, and manipulate files in the .tar
(tape archive) format.
Here are a few examples of how to use tar
:
- Create a new
.tar
archive:
tar -cvf archive.tar /path/to/folder
- Extract the contents of an existing
.tar
archive:
tar -xvf archive.tar -C /path/to/extract/to
- Extract the contents of a
.tar.gz
archive:
tar -xzvf archive.tar.gz -C /path/to/extract/to
- Extract the contents of a
.tar.bz2
archive:
tar -xjvf archive.tar.bz2 -C /path/to/extract/to
- View the contents of a
.tar
archive without extracting it:
tar -tvf archive.tar
- Add new files to an existing
.tar
archive:
tar -rvf archive.tar /path/to/new/file
These are just a few examples of how to use the tar
command. There are many more options and variations that can be used to perform various tasks.
0 Comments