Table of Contents
In this article, I will take you through the steps to Install jq(JSON Processor) on RHEL/CentOS 7/8. If you are working with JSON then you might be aware of jq tool which is being used to query and process the JSON output on Linux Based Servers. jq is an open source tool available from EPEL Repository which can be easily installed in any of the Linux Servers in just few steps. Often Programmers and Developers uses this tool along with some other tools to process the JSON output. More on JSON Official website.
What is JSON
JSON is known as JavaScript Object Notation. It is based on JavaScript Programming Language and is used to store the data in name value pairs format. It can be used with variety of other programming Language likes C, C++, Java, Python, Perl and many more.
What is jq
jq is known as JSON Processor. It is an open source tool available on Linux Based System to process the JSON output and query the desired results. This tool can easily be integrated and used with other Linux friendly scripting languages like Python and Bash.
How to Install jq(JSON Processor) tool on RHEL/CentOS 7/8
Also Read: How to Defragment an XFS Filesystem in Linux(5 Simple and Effective Steps)
Step 1: Prerequisites
a) You require a running RHEL/CentOS 7/8
Server.
b) You should have yum
installed in your Server. You can check Top 22 YUM command examples in RedHat/CentOS 7 to know more about yum
command.
c) You should have root
or sudo
access to run Privileged commands on your Server. Please Check How to Add User to Sudoers to know more about providing sudo
access to the User.
Step 2: Install EPEL Repository
JQ(JSON Processor)
utility is available through EPEL Repository so to install jq
you need to first install EPEL Repository by using yum install epel-release -y
command as shown below.
[root@localhost ~]# yum install epel-release -y Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: centos.hbcse.tifr.res.in * extras: centos.hbcse.tifr.res.in * updates: centos.hbcse.tifr.res.in Resolving Dependencies --> Running transaction check ---> Package epel-release.noarch 0:7-11 will be installed --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================================================================================== Package Arch Version Repository Size ======================================================================================================================================================================== Installing: epel-release noarch 7-11 extras 15 k Transaction Summary ======================================================================================================================================================================== Install 1 Package Total download size: 15 k Installed size: 24 k Downloading packages: epel-release-7-11.noarch.rpm | 15 kB 00:00:01 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : epel-release-7-11.noarch 1/1 Verifying : epel-release-7-11.noarch 1/1 Installed: epel-release.noarch 0:7-11 Complete!
Step 3: Update Your Server
If you have not updated your Server from long time then it is always recommended to first update your server with latest available releases using yum update -y command and then proceed for new package installation.
[root@localhost ~]# yum update -y Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: centos.hbcse.tifr.res.in * epel: mirror.poliwangi.ac.id * extras: centos.hbcse.tifr.res.in * updates: centos.hbcse.tifr.res.in Resolving Dependencies --> Running transaction check ---> Package epel-release.noarch 0:7-11 will be updated ---> Package epel-release.noarch 0:7-12 will be an update --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================================================================================== Package Arch Version Repository Size ======================================================================================================================================================================== Updating: epel-release noarch 7-12 epel 15 k Transaction Summary ======================================================================================================================================================================== Upgrade 1 Package Total download size: 15 k Downloading packages: epel/x86_64/prestodelta | 469 B 00:00:00 epel-release-7-12.noarch.rpm | 15 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Updating : epel-release-7-12.noarch 1/2 Cleanup : epel-release-7-11.noarch 2/2 Verifying : epel-release-7-12.noarch 1/2 Verifying : epel-release-7-11.noarch 2/2 Updated: epel-release.noarch 0:7-12 Complete!
Step 4: Install jq(JSON Processor) tool
If everything goes well you can now install jq
on RHEL/CentOS 7/8
using yum install jq -y
command as shown below.
[root@localhost ~]# yum install jq -y Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile epel/x86_64/metalink | 6.5 kB 00:00:00 * base: centos.hbcse.tifr.res.in * epel: epel.mirror.angkasa.id * extras: centos.hbcse.tifr.res.in * updates: centos.hbcse.tifr.res.in epel | 4.7 kB 00:00:00 (1/2): epel/x86_64/updateinfo | 1.0 MB 00:00:01 (2/2): epel/x86_64/primary_db | 6.9 MB 00:00:26 Resolving Dependencies --> Running transaction check ---> Package jq.x86_64 0:1.6-2.el7 will be installed --> Processing Dependency: libonig.so.5()(64bit) for package: install jq-1.6-2.el7.x86_64 --> Running transaction check ---> Package oniguruma.x86_64 0:6.8.2-1.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================================================================================== Package Arch Version Repository Size ======================================================================================================================================================================== Installing: jq x86_64 1.6-2.el7 epel 167 k Installing for dependencies: oniguruma x86_64 6.8.2-1.el7 epel 181 k Transaction Summary ======================================================================================================================================================================== Install 1 Package (+1 Dependent package) Total download size: 348 k Installed size: 1.0 M Downloading packages: (1/2): jq-1.6-2.el7.x86_64.rpm | 167 kB 00:00:00 (2/2): oniguruma-6.8.2-1.el7.x86_64.rpm | 181 kB 00:00:01 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Total 180 kB/s | 348 kB 00:00:01 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : oniguruma-6.8.2-1.el7.x86_64 1/2 Installing : jq-1.6-2.el7.x86_64 2/2 Verifying : oniguruma-6.8.2-1.el7.x86_64 1/2 Verifying : jq-1.6-2.el7.x86_64 2/2 Installed: jq.x86_64 0:1.6-2.el7 Dependency Installed: oniguruma.x86_64 0:6.8.2-1.el7 Complete!
Step 5: Verify jq package Installation
You can also verify the jq package installation by querying the package from RPM DB using rpm -qa | grep -i jq command as shown below.
[root@localhost ~]# rpm -qa | grep -i jq jq-1.6-2.el7.x86_64
Step 6: Check jq version
To check the installed jq version you need to use jq -Version
command as shown below. As you can see from below output, current version is 1.6
.
[root@localhost ~]# jq -Version jq-1.6
Step 7: Using jq(JSON Processor) tool
If you have some JSON output like below and you want to query the value of user
then you need to use jq .user
command to get the value of user
.
{
"user" : "admin",
"Modifieddate" : "Nov 10, 2015 11:26:10 PM GMT",
"Accesseddate" : "Nov 10, 2015 11:26:10 PM GMT"
}
To get the user from above output you can use jq .user
command as shown below.
jq .user
Step 8: Remove jq(JSON Processor) from Server
Once you are done with jq
utility you can uninstall this tool by using yum remove jq -y
command as shown below.
[root@localhost ~]# yum remove jq -y Loaded plugins: fastestmirror Resolving Dependencies --> Running transaction check ---> Package jq.x86_64 0:1.6-2.el7 will be erased --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================================================================================== Package Arch Version Repository Size ======================================================================================================================================================================== Removing: jq x86_64 1.6-2.el7 @epel 381 k Transaction Summary ======================================================================================================================================================================== Remove 1 Package Installed size: 381 k Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Erasing : jq-1.6-2.el7.x86_64 1/1 Verifying : jq-1.6-2.el7.x86_64 1/1 Removed: jq.x86_64 0:1.6-2.el7 Complete!
Step 9: Remove EPEL Repository
You can even remove the EPEL repository by using yum remove epel-release -y command if not required anymore.
[root@localhost ~]# yum remove epel-release -y Loaded plugins: fastestmirror Resolving Dependencies --> Running transaction check ---> Package epel-release.noarch 0:7-12 will be erased --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================================================================================== Package Arch Version Repository Size ======================================================================================================================================================================== Removing: epel-release noarch 7-12 @epel 24 k Transaction Summary ======================================================================================================================================================================== Remove 1 Package Installed size: 24 k Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Erasing : epel-release-7-12.noarch 1/1 Verifying : epel-release-7-12.noarch 1/1 Removed: epel-release.noarch 0:7-12 Complete!
Popular Recommendations:-
How to Install Arpwatch tool on RHEL/CentOS 7/8(Simple and Effective Steps)
How to Install and Configure Squid Proxy Server on RHEL/CentOS 7/8
Python3: ModuleNotFoundError: No Module Named "prettytable" in Linux
How to List all the Installed Python Modules in Linux{2 Easy Methods}
Solved: ModuleNotFoundError: No Module Named "requests" in Python 3
How to Install and Enable EPEL Repository on RHEL/CentOS 7/8{Simple and Easy Steps}
Primitive Data Types in Java - int, char, byte, short, long, float, double and boolean