Basic Format
tar [options] [archive-file] [file or directory to be archived]Key Expressions
-c | Create archive |
|
-x | Extract archive |
|
-t | Display contents of archive |
|
-r | Append files to existing archive |
|
-u | Archive, only include newer files |
|
-v | Verbose, show progress |
|
-f | Allows you to specify the name of the archive |
|
-z | Compress the archive using gzip |
|
-j | Compress the archive using bzip2 |
|
-J | Compress the archive using xz |
|
-Z | Compress the archive using compress |
Examples
tar -cf archive.tar file1 file2
Create an archive (archive.tar) from files (file1, file2)
tar -xf archive.tar
Extract files from an archive (archive.tar)
tar -czf archive.tar.gz directory
Create a gzip compressed tar file (archive.tar.gz) from a dir
tar -xzf archive.tar.gz
Extract a gzip compressed tar file
tar -cjf archive.tar.bz2 directory
Create a bzip2 compressed tar file from a directory
tar -xjf archive.tar.bz2
Extract a bzip2 compressed tar file
tar -tvf archive.tar
List the contents of the archive