Skip to main content

TAR Archive Commands

TAR (No Compression)

Create TAR Archive

Create a TARarchive from a directory. "-cf" is to create and append. No compression.

tar -cf <filename> <dir>

Extract TAR Archive

Extract the TAR file to the current directory.

tar -xf <filename>

View TAR Archive

View the content of the TAR file.

tar -tf <filename>

TAR (With Compression)

Create a TAR file with compression

Create a TAR archive with compression. The order of the letter is important.

(gzip) $ tar -czf <filename> <dir> 
(bzip2) $ tar -cjf <filename> <dir>
(xz) $ tar -cJf <filename> <dir>

Extract a compressed TAR file

Extract a compressed TAR file to the current directory.

(gzip) $ tar -xzf <filename>
(bzip2) $ tar -xjf <filename>
(xz) $ tar -xJf <filename>

Preserve Permission and Verbose

Create a compressed TAR file and preserve permissions.

(gzip) $ tar -cvpzf <filename> <dir> 
(bzip2) $ tar -cvpzf <filename> <dir>
(xz) $ tar -cvpzf <filename> <dir>





 

permission gzip