April 21, 2021



Linux – Create and extract Tar files


Probably the most used compression for Linux systems, and maybe the Linux equivalent of Zip. Tar stands for “Tape Archive”, and was made back in the old days to archive files to tape drives.

To create a compressed file with Jons test files:
tar -cvf archived.tar /home/jon/testfiles

-cvf is the switches, arguments or commands if you like, and means:
c – is the first argument and is the function named create
v – verbose, text output (you can leave this out, but you get no text output of what files it compress)
f – Archive filename

To extract a tar file:
tar -xvf archived.tar

To extract a tar to a specific firectory:
tar -xvf archived.tar /home/jon/archive/

-xvf is the switches you need to extract a tar file. Or you can leave the v (verbose).
x – Means extract

Happy compressing!