Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

jq Command Not Found: Quick Fix for Bash

· 7 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

The "command jq not found" error in bash means the jq utility is not installed on your system or is not in your PATH. The fastest fix is to install it with your package manager: on Debian/Ubuntu run sudo apt install jq, on Fedora run sudo dnf install jq, on macOS with Homebrew run brew install jq, and on Windows use winget install jqlang.jq or install it inside WSL. After installation, open a new terminal or run hash -r so bash picks up the new binary, then verify with jq --version. The steps below walk through identifying your system, installing, and confirming the fix, plus what to do if the install succeeds but bash still cannot find jq.

What You'll Need

  • A terminal or command prompt with bash (Linux, macOS, WSL, Git Bash, or a similar environment).
  • Administrative rights on the machine (sudo on Linux/macOS, an elevated prompt on Windows) to install system packages.
  • An internet connection to download the package.
  • Knowledge of which operating system and package manager you are using. If you are unsure, run cat /etc/os-release on Linux or uname -a on macOS/Linux.

Step-by-Step

  1. Confirm the error and check whether jq exists anywhere. Run command -v jq. If it prints nothing, jq is not on your PATH. Run type -a jq to see whether bash finds any alias or function named jq. If type -a finds a file but jq --version fails, the binary may be broken or built for another architecture.
  2. Identify your platform and package manager. On Linux, cat /etc/os-release tells you the distribution. Debian and Ubuntu use apt; Fedora, RHEL, and Rocky use dnf; Arch and Manjaro use pacman; Alpine uses apk; openSUSE uses zypper. On macOS, check whether Homebrew is installed with brew --version. On Windows, decide whether you are working in WSL (use the Linux instructions inside WSL) or in Git Bash/PowerShell (use winget or the official Windows binary).
  3. Install jq with the package manager for your system. Use the command that matches your platform:
    • Debian/Ubuntu: sudo apt update && sudo apt install jq
    • Fedora/RHEL/Rocky: sudo dnf install jq
    • Arch/Manjaro: sudo pacman -S jq
    • Alpine: sudo apk add jq
    • openSUSE: sudo zypper install jq
    • macOS with Homebrew: brew install jq
    • Windows with winget: winget install jqlang.jq
    If your package manager is not listed, search its repository for "jq" or download the official binary from the jq project's release page and place it in a directory on your PATH.
  4. Refresh bash's command cache. Bash caches the location of commands it has already looked up. After installing, run hash -r in the current shell, or simply close and reopen the terminal. This is the step most people miss when the install succeeds but the "command not found" message persists.
  5. Verify the installation. Run jq --version. You should see output such as jq-1.7 (the exact version depends on your package manager). Then test with a real filter: echo '{"a":1}' | jq '.a' should print 1.
  6. If jq is installed but still not found, check your PATH. Run echo "$PATH" and confirm the directory containing jq is listed. On most Linux systems jq lands in /usr/bin/jq; with Homebrew on Apple Silicon it is typically /opt/homebrew/bin/jq, and on Intel Macs /usr/local/bin/jq. If the directory is missing, add it to your shell profile (for example export PATH="/opt/homebrew/bin:$PATH" in ~/.bashrc or ~/.bash_profile) and reload with source ~/.bashrc.
  7. Handle permission and architecture problems. If jq --version returns "Permission denied", run chmod +x /path/to/jq. If it returns "cannot execute binary file" or "Exec format error", you downloaded a build for the wrong CPU architecture or OS; reinstall through the package manager or download the correct official binary.

Common Mistakes

  • Not refreshing the shell. Installing jq in one terminal does not update other open terminals. Run hash -r or open a new window.
  • Installing with a different user than the one running bash. A package installed inside a container, a virtual environment, or another user account will not be visible in your current shell.
  • Confusing jq with other tools. Some systems have a different program or alias named jq. Check type -a jq to see exactly what bash resolves.
  • Using sudo unnecessarily. Once installed, run jq as your normal user. Running sudo jq can create files owned by root and cause later permission errors.
  • Downloading binaries from unofficial sources. Use your distribution's package manager, Homebrew, winget, or the official jq project release page. Avoid random third-party mirrors.
  • Editing the wrong profile file. Bash reads ~/.bashrc for interactive non-login shells and ~/.bash_profile or ~/.profile for login shells. If your PATH change does not stick, you edited the file your shell does not read.

Tips

  • Run command -v jq first whenever you see "command not found"; it tells you quickly whether the problem is installation or PATH.
  • Prefer your package manager over manual downloads so updates and security fixes arrive with normal system updates.
  • On macOS, if Homebrew is not installed, install it from the official Homebrew site first, then run brew install jq.
  • On Windows, WSL gives you a full Linux environment where the standard package manager commands work; Git Bash users can use winget or place the official jq.exe on the PATH.
  • Keep a note of the install command for each machine you use; it saves time when setting up a new development environment.
  • If you script with jq, check for it at the start of the script with command -v jq >/dev/null || { echo "jq is required"; exit 1; } so failures are clear.

Troubleshooting

If jq --version still reports "command not found" after installation, work through these checks in order:

  1. Reopen the terminal. Close every terminal window and open a fresh one. This clears the command cache and reloads your shell profile.
  2. Check where the package manager put the binary. On Linux, dpkg -L jq (Debian/Ubuntu) or rpm -ql jq (Fedora/RHEL) lists installed files. On macOS, brew --prefix jq shows the install location.
  3. Confirm the directory is on PATH. Compare the binary's directory with echo "$PATH". Add it to your shell profile if missing, then reload the profile.
  4. Check for a broken symlink. Run ls -l $(command -v jq) if command -v returns a path. A symlink pointing to a deleted file causes confusing errors; reinstall the package to repair it.
  5. Test with the absolute path. Run /usr/bin/jq --version (or the path you found). If that works, the binary is fine and the problem is PATH or shell caching.
  6. Reinstall the package. Remove it with your package manager and install it again. This is safe and does not affect your data.
  7. Check your shell. If you use zsh or fish, the PATH changes belong in that shell's profile file, not ~/.bashrc. The error message in bash specifically means bash cannot find the command, so verify you are actually in bash with echo "$SHELL".

If none of this works, the machine may be locked down by an administrator or a container image without package access. In that case, ask the administrator to install jq, or use a container image that includes it.

Frequently Asked Questions

What does "jq: command not found" actually mean?

It means bash could not find an executable named jq in any directory listed in your PATH. Either jq is not installed, or it is installed somewhere bash does not search.

Do I need sudo to install jq?

Yes, for system-wide installs with apt, dnf, pacman, apk, or zypper. Homebrew installs for your user and does not need sudo. Never run jq itself with sudo once it is installed.

Why does jq work in one terminal but not another?

The other terminal was opened before jq was installed and still has the old command cache. Run hash -r in that terminal or open a new one.

Can I use jq on Windows without WSL?

Yes. Install it with winget (winget install jqlang.jq) or download the official Windows binary and add its folder to your PATH. In Git Bash, the same commands work once jq.exe is on the PATH.

Is jq the same as the jq command in some other language?

No. jq is a standalone JSON processor. Some shells or tools may define an alias named jq; run type -a jq to see what bash is actually resolving.

How do I check which version of jq I have?

Run jq --version. The output shows the version number, for example jq-1.7. The exact version depends on your package manager and when it was last updated.