tar
stands for ‘tape archive’. It’s a widely known and used command, useful to create compressed archive files and decompress them. tar
syntax is rather unorthodox.
Create compressed archive
For tar.gz
:
# tar cvzf foobar.tar.gz /home/foobar
# tar cvzf foobar.tgz /home/foobar
For tar.bz2
:
# tar cvjf foobar.tar.bz2 /home/foobar
Extract archive
# tar xvf <archive>
To extract content into a given directory:
# tar xvf <archive> -C /path/to/directory;
List archive content
# tar tvf <archive>
Extract only a given file
# tar xvf <archive> <file>
Add file to an archive
# tar rvf <archive> <file>