How to Create the tar file then gzip the file on RHEL 6

In Red Hat Enterprise Linux 6, you can create a tar file to archive multiple files and directories into a single file, and then compress the tar file using gzip to reduce its size. This can be useful for backups, data transfer, and storage management. In this guide, we will show you how to create a tar file and then gzip the file on Red Hat Enterprise Linux 6.

Step 1: Create a Tar File

To create a tar file, you can use the tar command. For example, if you want to archive the /home/user/Documents directory, you can run the following command:

tar -cvf documents.tar /home/user/Documents

This command will create a tar file named documents.tar in the current directory that contains all the files and directories under /home/user/Documents. The -c option tells tar to create a new archive, -v means verbose output, and -f specifies the output file name.

See also  How to Install Vsftpd Ftp Server on RHEL 6

Step 2: Gzip the Tar File

Once you have created the tar file, you can use gzip command to compress it. Run the following command:

gzip documents.tar

This command will compress the documents.tar file into a smaller file named documents.tar.gz. The original tar file will be deleted, and only the compressed file will remain.

Commands Mentioned:

  • tar -cvf – Create a tar file
  • gzip – Compress a file using gzip


In this guide, we have shown you how to create a tar file and then gzip the file on Red Hat Enterprise Linux 6. By using these commands, you can create an archive of multiple files and directories and then compress it to save disk space or transfer it over a network. We hope this guide has been helpful to you. If you have any comments or suggestions for improvements, please feel free to share them below.