Tar command Cheat Sheet

Updated: 2023-09-01
1 min read
[Linux CLI tar cheatsheet]

Common options

z compress with gzip
c create an archive
u append files which are newer than 
    the corresponding copy ibn the archive
f filename of the archive
v verbose, display what is inflated or deflated
a unlike of z, determine compression based on file extension

Create tar named archive.tar containing directory

tar cf archive.tar /path/files

Concatenate files into a single tar

tar -cf archive.tar /path/files

Extract the contents from archive.tar

tar xf archive.tar

Create a gzip compressed tar file name archive.tar.gz

tar czf archive.tar.gz /path/files

Extract a gzip compressed tar file

tar xzf archive.tar.gz

Create a tar file with bzip2 compression

tar cjf archive.tar.bz2 /path/files

Extract a bzip2 compressed tar file

tar xjf archive.tar.bz2

List content of tar file

tar -tvf archive.tar