How to Install Jq on Ubuntu 22.04

Install Jq on Ubuntu 22.04

In this article, we will have explained the necessary steps to install Jq on Ubuntu 22.04 LTS. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

Jq software package provides a lightweight and flexible command-line JSON processor. Jq can mangle the data format that you have into the one that you want with very little effort, and the program to do so is often shorter and simpler than you’d expect.

Prerequisite:

  • Operating System with Ubuntu 22.04
  • Server IPv4 Address with Superuser Privileges (Root Access)
  • Gnome Terminal for Linux Desktop
  • PuTTy SSH client for Windows or macOS
  • Powershell for Windows 10/11
  • Familiar with APT Commands

Install Jq on Ubuntu 22.04 LTS

Step 1. First, before you start installing any package on your Ubuntu server, we always recommend making sure that all system packages are updated.

sudo apt update
sudo apt upgrade
sudo apt install build-essential libpcap-dev libpcre3-dev libnet1-dev zlib1g-dev luajit hwloc libdnet-dev libdumbnet-dev bison flex liblzma-dev openssl libssl-dev pkg-config libhwloc-dev cmake cpputest libsqlite3-dev uuid-dev libcmocka-dev libnetfilter-queue-dev libmnl-dev autotools-dev libluajit-5.1-dev libunwind-dev libfl-dev

Step 2. Install Jq on Ubuntu.

Snort installation is quite easy and straightforward since the Jq package is accessible in the repositories of the majority of Linux distributions. Now You can follow the steps given below for installing Jq:

sudo apt install jq

When the installation is finished, check Jq version:

jq --version

Step 3. Testing Jq on Ubuntu.

Let’s say we have JSON data stored in the test.json file:

echo '{"status":"success","data":[{"name":"Meilana","age":25},{"name":"Maria","age":29}]}' > test.json

The Jq tool supports various filters that can be applied to JSON data. For example, the dot . filter prints unchanged but nicely formatted JSON:

jq '.' test.json

Output:

{
  "status": "success",
  "data": [
    {
      "name": "Meilana",
      "age": 25
    },
    {
      "name": "Maria",
      "age": 29
    }
  ]
}

We can retrieve a particular field of a JSON object or an element of a JSON array as follows:

jq '.data[1].name' test.json

Output:

"Meilana"

That’s all you need to do to install Jq on Ubuntu 22.04 LTS Jammy Jellyfish. I hope you find this quick tip helpful. For further reading on the installation of the Jq flexible command-line JSON processor, please refer to their official knowledge base. I hope this article was helpful to you. If you find it useful, don’t forget to share it with your friend and family. Also, if you have any questions, please feel free to ask in the comments section. We are always there to assist you.