Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Servers, nginx and Docker

You installed Go on Ubuntu but the go command is not found or the install is broken

Errorgo: command not found

Short answer

The Go tarball puts everything in /usr/local/go, but the shell only runs programs on PATH. Add /usr/local/go/bin to PATH in your profile and log in again. If Go was unpacked over an older tree, remove /usr/local/go and extract the archive fresh; the docs say overwriting breaks installs.

  • Applies to Go 1.24, Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    See whether the binary exists on disk and whether its folder is on PATH.

    ls -l /usr/local/go/bin/go
    echo $PATH
  2. 2Match what you see, then jump to its fix

    1. 1ls finds the go binary but the shell does not/usr/local/go/bin is not on PATHFix
    2. 2go exists but fails with missing packages or odd compile errors after an upgradeThe archive was extracted over an existing Go treeFix

What does the error look like?

  • go: command not found
  • go version works for one user but not in a fresh login shell

Cause 1 of 2

/usr/local/go/bin is not on PATH

1Check

Go's install guide has you add the bin folder to PATH yourself. Nothing does it for you after you extract the archive.

grep -n "go/bin" ~/.profile /etc/profile

2Fix

Add the export line to $HOME/.profile (or /etc/profile for all users) and log in again, or run it once in the current shell.

echo 'export PATH=$PATH:/usr/local/go/bin' >> $HOME/.profile
export PATH=$PATH:/usr/local/go/bin

3Verify

go prints its version.

go version

Confirmed by go.dev

Did this fix it?

Cause 2 of 2

The archive was extracted over an existing Go tree

1Check

Do not untar the archive into an existing /usr/local/go tree; this is known to produce broken Go installations.

ls /usr/local/go

2Fix

Remove the old folder and extract the archive into /usr/local again. Use the file name of the archive you downloaded.

sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.24.0.linux-amd64.tar.gz

3Verify

Check the version and build a small program.

go version

Confirmed by go.dev

Did this fix it?

How do I stop it coming back?

  • Follow the official install steps from go.dev for each upgrade, in the same order.
  • Keep the PATH line in one place only, so two copies do not point at different Go versions.
  • Run go version after every login shell change.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Related fixes

Servers

dnf cannot install MySQL on Amazon Linux 2023

dnf cannot find a mysql-server package on Amazon Linux 2023

Amazon Linux 2023 documents MariaDB, not MySQL, as its database server, with packages named mariadb105 and mariadb105-server.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.