gh command not found

In this troubleshooting guide we learn how to fix gh command not found error message

Introduction

When you run more command in linux terminal / console, you get the following error message

gh: command not found

or when using sudo you get the following error message

sudo: gh: command not found

Solutions to gh: command not found

How To Fix gh: command not found in Ubuntu / Debian / Kali Linux / Raspbian

In Ubuntu gh is provided by gh package.

gh is:

GitHub CLI “gh” is GitHub on the command line. It brings pull requests, issues, and other GitHub concepts to the terminal next to where you are already working with git and your code.

GitHub CLI is available for repositories hosted on GitHub.com and GitHub Enterprise Server 2.20+, and to install on macOS, Windows, and Linux.

Comparison with hub:

For many years, hub (https://github.com/github/hub) was the unofficial GitHub CLI tool. gh is a new project that helps us explore what an official GitHub CLI tool can look like with a fundamentally different design. While both tools bring GitHub to the terminal, hub behaves as a proxy to git, and gh is a standalone tool. Check out the more detailed explanation at https://github.com/cli/cli/blob/trunk/docs/gh-vs-hub.md to learn more.

To fix this problem, we can install more using the command below.

sudo apt-get -y install gh

This command might take some time to finish depending on your machine internet connection.

You can also use apt command to install gh.

sudo apt -y install gh

Or if you have aptitude installed you can use the following command.

sudo aptitude install gh

Summary

In this tutorial we learn how to fix gh command not found error in Ubuntu / Debian / Kali Linux or Raspbian distribution.