How to create a .tar.gz file from the command line

If you are using the terminal or console to manage your server (most Linux distributions) and want to create a .tar.gz archive. Use the following command to create the archive of the file or folder.

Replace /home/whatever with the full location to the directory or folder that you want to archive. Change the custom-name-for-archive.tar.gz to your desired name for the .tar.gz archive.
tar -zcf custom-name-for-archive.tar.gz /home/whatever

The following is used to archive a single file instead of a folder. Replace saveme.txt with the exact file name of the file that you want to create a .tar.gz archive of. If the file is located in a different folder than you will have to use the exact location to the file.
tar -zcf custom-name-for-archive.tar.gz saveme.txt

To change the location of where the .tar.gz archive is saved. You can replace custom-name-for-archive.tar.gz with the exact location where you want the archive to be saved to.