11 Feb 18
Compress and Extract Files using tar on command line
As web developers, we deal with ‘tar.gz’ archives quite often. Here are a few useful commands.
Creating a ‘tar.gz’ archive from a directory
tar -zcvf archive-name.tar.gz directory-name
Extracting a ‘tar.gz’ archive
tar -zxvf archive-name.tar.gz
Option types for tar
There are various ways to specify options when using the ‘tar’ command:
- tar -z -x -v -f archive-name.tar.gz
- tar -zxvf archive-name.tar.gz
- tar zxvf archive-name.tar.gz
- tar –extract -verbose -gzip – file archive-name.tar.gz
For further information about all the options, you can use the command line man page or online