tar and gzip files from linux command line

Sometimes it’s hard to remember all the options you need to include to tar and gzip files or a folder from the command line. Here it is…

tar -cvzf tarballname.tar.gz myfilestocompress

To untar and unzip simply do:

tar xvfz filename.tar.gz

And if there are only certain files you want in the tar then do:

tar xvzf filename.tar.gz */dir.you.want/*