You installed Go on Ubuntu but the go command is not found or the install is broken
go: command not foundShort 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.
Fix it fast
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 $PATH2Match what you see, then jump to its fix
What does the error look like?
go: command not foundgo 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/profile2Fix
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/bin3Verify
go prints its version.
go versionConfirmed by go.dev
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/go2Fix
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.gz3Verify
Check the version and build a small program.
go versionConfirmed by go.dev
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 fixServers
Ansible hangs, then times out waiting for the sudo prompt
a playbook using become seems to hang
Ansible ran sudo on the target and never saw the answer it expected.
3 causes, each with a fixServers
Apache on Ubuntu returns 404 Not Found for my site
The requested URL was not found on this server.
On Ubuntu a 404 from Apache usually means the request maps to a path that has no file.
3 causes, each with a fixServers
Apache returns 504 Gateway Timeout when PHP takes too long
Quick requests work, slow ones end in a 504 after a fixed wait
A 504 from Apache means the backend did not answer within the proxy timeout.
2 causes, each with a fixServers
Apache logs SIGWINCH and exits on its own
the httpd container stops although nothing crashed
SIGWINCH is Apache's graceful-stop signal.
2 causes, each with a fixServers
Apache warns that a ${VAR} config variable is not defined
${VAR} left unchanged in the configuration, with a warning in the error log
Apache expands ${VAR} from Define or from the shell environment that exists when the server starts.
3 causes, each with a fix