tar



Overview


• Stands for taped archive. Used since 1970s
Rule of thumb: create archive or compress from outside of containing directory i.e. one directory above (see tar bomb below)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Archiving


• The process of taking all files and directories under a hierarchial structure and create a single file (*.tar) that contains all of those things
• Archiving and Compression are two separate things

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View Contents



tar -tf filename.tar.gz

# t - list
# f - use archive file


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Compress



tar -zcvf docs.tar.gz Documents/

# z - compress using gzip
# c - create archive
# v - verbose (optional)


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Uncompress



tar -zxvf docs.tar.gz

#  x - extract


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tar bomb (common mistake)



tar -zcf ../tarbomb.tar.gz


• When the file is de-compreesed, it will glow up into many directories and files and mix up with existing files

Index