How to Install tar in CentOS, RHEL, and Fedora

tar is a widely used command-line based utility for combining a bunch of files and/or directories into one archive file, commonly known as a tarball for backup or distributions purposes. The tar command is used to create, maintain, modify, or extract tar archives.

Read Also: 5 Best Command Line Archive Tools for Linux

Note that tar does not compress archive files by default, but, it can compress the resulting archive using (or filter it through) well-known data compression programs such as gzip, bzip2, or xz if you supply the -z, -j, or -J flags.

Installing tar in CentOS, RHEL, and Fedora

The tar package comes pre-installed in most if not all Linux distributions by default. But if it is not installed on your system, run the following command to install it.

# yum install tar

Once you have tar installed on your system, you can use it as follows. This example shows how to create an uncompressed archive file of a directory called test_app within the working directory.

# tar -cvf test_app.tar test_app/
Create Uncompressed Tarball
Create Uncompressed Tarball

In the above command, the tar flags used are -c which creates a new .tar archive file, -v enables verbose mode to show the .tar file creation progress, and -f which specifies the file name type of the archive file (test_app.tar in this case).

To compress the resulting archive file using gzip or bzip2, supply the -z or -j flag as follows. Note that a compressed tarball can also end with the .tgz extension.

# tar -cvzf test_app.tar.gz test_app/
# tar -cvzf test_app.tgz test_app/
# tar -cvjf test_app.tar.bz2 test_app/
Create Compressed Tarball
Create Compressed Tarball

To list the contents of a tarball (archived file), use the -t flag as follows.

# tar -ztf test_app.tar.gz
# tar -ztvf test_app.tar.gz		#shows more details
View Contents of Tarball
View Contents of Tarball

To extract (or untar) an archive file, use the -x switch as shown.

# tar -xvf test_app.tar
# tar -xvf test_app.tar.gz 

For more usage examples, see our following articles:

That’s all for now! In this article, we have shown how to install tar in CentOS, RHEL & Fedora and also showed some basic tar usage commands. If you have any queries, share it with us via the feedback form below.

If you liked this article, then do subscribe to email alerts for Linux tutorials. If you have any questions or doubts? do ask for help in the comments section.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

7 thoughts on “How to Install tar in CentOS, RHEL, and Fedora”

  1. You have titled installing ‘tar‘. Is it not tar comes preinstalled in all Unix/Linux similar to ‘vi’ editor. You have discussed about usage of tar rather than installing of tar program itself. Am I not right?

  2. This type of articles people search before 10 years from now a days. People are smart. Basic ABC article don’t have any value in market don’t waste your time to publish such a oldie articles. People don’t read.

    • @Rahul,

      This kind of article still useful for Linux beginners, who don’t have any prior knowledge about commands and all. Everyone goes through the beginning stage, it doesn’t mean that we learned everything…


Got something to say? Join the discussion.

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.