Loading
All articles
Software & Tools 13 min read

How to Install Go on Linux (Ubuntu and Fedora): A Visual, Hands-On Guide

Install Go on Linux three ways, tested for real: apt on Ubuntu, dnf on Fedora, and the official download from go.dev, with versions, download and disk sizes, checksums, PATH setup, a first program, upgrading, and how to pick the right method.

nbkhope
On this page

Before you can build a Go program you need the Go toolchain: the compiler, the linker, the standard library and the go command that drives them all. On Linux there are two common ways to get it: your distribution's package manager, or the official download from go.dev. They're both easy, but they don't give you the same thing.

We installed Go every way this guide describes, in fresh Ubuntu 22.04, Ubuntu 24.04 and Fedora 44 systems, and recorded what each one actually installed: the Go version, the download size, the disk space and the time. Then we picked a winner for each situation.

All outputs below come from those real installs (run in clean containers in October 2026). Versions move fast, so yours will be newer.

Three ways to install

Three ways to install Go on Linux. 1, Ubuntu or Debian: sudo apt install golang-go. Easy and updated with the rest of the system, but the version is fixed for the life of that Ubuntu release: Go 1.22.2 on Ubuntu 24.04, Go 1.18.1 on Ubuntu 22.04. 2, Fedora: sudo dnf install golang. Easy, and Fedora ships recent versions: Go 1.26.10 on Fedora 44. 3, Official download from go.dev: download a tarball, check its checksum, extract it to /usr/local/go and add it to PATH. Always the newest release, Go 1.27.3, the same on every distribution, upgraded by hand. All three give you the same go command
MethodCommandGo version we gotBest for
Ubuntu / Debian packagesudo apt install golang-go1.22.2 (Ubuntu 24.04), 1.18.1 (Ubuntu 22.04)Quick start, older is OK
Fedora packagesudo dnf install golang1.26.10 (Fedora 44)Fedora users
Official downloadtarball from go.dev1.27.3 (newest)Real projects, any distro

Is Go already installed?

Open a terminal and ask for the version:

1$ go version
2Command 'go' not found, but can be installed with:
3sudo apt install golang-go  # version 2:1.21~2, or
4sudo apt install gccgo-go   # version 2:1.21~2

That's Ubuntu's friendly "command not found" helper, suggesting packages. (The 2:1.21~2 is the version of a small package that points to the real Go package; the Go you actually get is shown below.) Other distributions just say bash: go: command not found. If instead you see a go version … line, Go is already there.

Method 1: Ubuntu and Debian (apt)

Refresh the package lists, then install the golang-go package:

1$ sudo apt update
2$ sudo apt install golang-go
3…
4Need to get 125 MB of archives.
5After this operation, 500 MB of additional disk space will be used.
6Do you want to continue? [Y/n] y
7…
8$ go version
9go version go1.22.2 linux/amd64

sudo runs the command as the administrator, which installing software requires. apt installs the toolchain into /usr/lib/go-1.22 and puts a go command in /usr/bin.

The catch is the version. Ubuntu freezes package versions when it releases, so the Go you get depends on your Ubuntu, not on what's current:

$ go version        # on Ubuntu 22.04
go version go1.18.1 linux/amd64

Go 1.18 came out in March 2022. New Go releases arrive every six months, and only the two newest get security fixes, so an old Ubuntu's Go is soon unsupported and can't build code that uses newer features.

Method 2: Fedora (dnf)

1$ sudo dnf install golang
2…
3Total size of inbound packages is 137 MiB. Need to download 137 MiB.
4After this operation, 506 MiB extra will be used (install 516 MiB, remove 10 MiB).
5Is this ok [y/N]: y
6…
7$ go version
8go version go1.26.10-X:nodwarf5 linux/amd64

Fedora updates fast, so dnf gave us a recent Go 1.26. (The -X:nodwarf5 suffix records an experiment setting Fedora builds Go with; it doesn't change how you use it.) The toolchain lives in /usr/lib/golang. dnf is the successor of the older yum command.

Method 3: The official download (any distribution)

This is the method the Go team documents, and it always gives you the newest release, identical on every distribution.

1. Download the Linux archive for your processor from go.dev/dl (amd64 for most PCs and servers, arm64 for ARM machines like a Raspberry Pi 4/5):

$ curl -LO https://go.dev/dl/go1.27.3.linux-amd64.tar.gz
$ ls -l go1.27.3.linux-amd64.tar.gz
-rw-rw-r-- 1 ada ada 70588678 Oct 24 23:10 go1.27.3.linux-amd64.tar.gz

2. Check the checksum. The download page lists a SHA-256 checksum for every file. Comparing it proves the download is complete and untouched:

$ echo "<checksum from go.dev/dl>  go1.27.3.linux-amd64.tar.gz" | sha256sum --check
go1.27.3.linux-amd64.tar.gz: OK

3. Extract it into /usr/local, after removing any previous Go installed this way (never extract over an old one):

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

4. Add Go to your PATH so the shell can find the go command. Add this line to the end of ~/.profile (or ~/.bashrc):

export PATH=$PATH:/usr/local/go/bin

Then log out and back in, or load it right away with source ~/.profile, and check:

$ go version
go version go1.27.3 linux/amd64

The whole thing took 11 seconds in our test: a 70.6 MB download that unpacks to 283 MB.

How the shell finds the go command. When you type go, the shell looks through the folders listed in the PATH environment variable, in order: /usr/local/sbin, /usr/local/bin, /usr/sbin, /usr/bin and so on. With the apt or dnf packages, go is already in /usr/bin, so it is found. With the official download, go lives in /usr/local/go/bin, which is not on the PATH until you add export PATH=$PATH:/usr/local/go/bin to ~/.profile. If go is not found, that line is missing or the shell has not reloaded it. If go version shows an unexpected version, two installs are on the PATH and the earlier folder wins

Comparing the methods

Which Go version does each method give you? Versions we got in October 2026, when the newest release was Go 1.27.3: Ubuntu 22.04 apt gave Go 1.18.1, from March 2022 and long out of support; Ubuntu 24.04 apt gave Go 1.22.2, from early 2024 and also out of support; Fedora 44 dnf gave Go 1.26.10, supported; the official download gave Go 1.27.3, the newest. Go releases a new version every six months, and only the two newest releases get security fixes
Download size, disk space and install time for each method, measured in clean containers. Ubuntu 24.04 apt with recommended packages: 125 MB download, 500 MB on disk, 43 seconds, 80 packages including GCC. Ubuntu 24.04 apt with --no-install-recommends: 45.7 MB, 228 MB, 6 seconds, 4 packages. Fedora 44 dnf: 137 MiB, 506 MiB, 33 seconds. Official download: 70.6 MB, 283 MB, 11 seconds. Times depend mostly on download speed
Ubuntu 24.04 aptFedora 44 dnfOfficial download
Go version1.22.21.26.101.27.3
Download125 MB (45.7 MB without recommends)137 MiB70.6 MB
Disk500 MB (228 MB without recommends)506 MiB283 MB
Time in our test43 s (6 s)33 s11 s
Toolchain folder/usr/lib/go-1.22/usr/lib/golang/usr/local/go
UpdatesWith the system, same version lineWith the systemBy hand

So which should you pick?

  • Learning, on Fedora or a recent Ubuntu: the package manager is fine.
  • Real projects, older Ubuntu, or a specific version: the official download. Modules can require a minimum Go version (the go 1.22 line in go.mod), and an old distro package may be too old.
  • Need several versions side by side? Install one officially, then let Go fetch others: since Go 1.21, a toolchain line in go.mod makes go download the exact version a project asks for automatically.

Your first program on Linux

Whichever method you used, test the whole toolchain with a tiny program (the first program guide explains every line):

1package main
2
3import "fmt"
4
5func main() {
6	fmt.Println("Hello from Linux!")
7}
1$ mkdir hello && cd hello
2$ go mod init hello
3go: creating new go.mod: module hello
4$ go run .
5Hello from Linux!

If that prints, the compiler, the standard library and the module system all work.

Where things live

1$ go env GOROOT
2/usr/local/go
3$ go env GOPATH
4/home/ada/go
  • GOROOT is the toolchain itself: the go command, the compiler and the standard library. You never put your own code there.
  • GOPATH (by default ~/go) is where Go keeps downloaded modules (~/go/pkg/mod) and programs you install with go install (~/go/bin). Add ~/go/bin to your PATH too if you install Go tools.
  • Your projects can live anywhere, each in its own folder with a go.mod.

Upgrading and uninstalling

MethodUpgradeUninstall
aptsudo apt update && sudo apt upgrade (stays on the same Go version line)sudo apt remove golang-go
dnfsudo dnf upgrade golangsudo dnf remove golang
Official downloadRemove /usr/local/go, extract the new tarballsudo rm -rf /usr/local/go, and remove the PATH line

On Windows or macOS?

  • Windows: run the .msi installer from go.dev/dl. It sets up PATH for you. Or install Linux itself with WSL (wsl --install) and follow this guide inside it.
  • macOS: run the .pkg installer from go.dev/dl, or use Homebrew: brew install go.

Your turn: practice

These check your understanding rather than your typing; try them before reading the answers.

Exercise 1: Read the version line. What does each part of go version go1.22.2 linux/amd64 tell you?

Exercise 2: Pick a method. For each situation, choose apt/dnf or the official download: (a) a student on Fedora 44 learning Go; (b) a server running Ubuntu 22.04 that must build a project whose go.mod says go 1.25; (c) a laptop where you want the newest Go the day it comes out.

Exercise 3: Fix the PATH. After extracting the official tarball, go version says bash: go: command not found. What's wrong, and what's the fix?

Exercise 4: Two Gos. You installed golang-go with apt last year and the official Go 1.27.3 today, but go version still prints go1.22.2. Why, and how do you check?

Exercise 5: Prove it works (challenge). Write the commands to check that Go is installed, that it's the version you expect, and that it can build and run a program.

Quick quiz

  1. Which package name do you install on Ubuntu?
  2. Why does apt install golang-go download 125 MB when Go itself is about 100 MB?
  3. Where does the official download put Go?
  4. Why check the SHA-256 checksum?
  5. What's the difference between GOROOT and GOPATH?

Answers

Exercise 1: go1.22.2 is the Go version (major 1, minor 22, patch 2); linux is the operating system and amd64 the processor architecture (64-bit x86) the toolchain is built for, which is also what it builds for by default.

Exercise 2: (a) sudo dnf install golang: Fedora's Go is recent. (b) The official download: Ubuntu 22.04's package is Go 1.18.1, too old for a module that needs 1.25. (c) The official download, which always has the newest release.

Exercise 3: The tarball puts go in /usr/local/go/bin, which isn't on the PATH. Add export PATH=$PATH:/usr/local/go/bin to ~/.profile, then run source ~/.profile (or log in again).

Exercise 4: The apt version lives in /usr/bin, which comes before /usr/local/go/bin in the PATH, so the shell finds it first. which go shows /usr/bin/go. Remove the apt package (sudo apt remove golang-go) or put /usr/local/go/bin earlier in the PATH.

Exercise 5: For example:

1$ go version
2go version go1.27.3 linux/amd64
3$ go env GOROOT
4/usr/local/go
5$ mkdir hello && cd hello && go mod init hello
6go: creating new go.mod: module hello
7$ go run .
8Hello from Linux!

(after writing the hello.go from this article in that folder).

Quiz: (1) golang-go. (2) By default apt also installs recommended packages, 80 in all, including the GCC compilers that cgo uses; --no-install-recommends skips them. (3) /usr/local/go, with the go command in /usr/local/go/bin. (4) To prove the file downloaded completely and wasn't tampered with. (5) GOROOT is the Go toolchain itself; GOPATH (default ~/go) holds downloaded modules and installed tools.

Cheat sheet

I want to…Run
Check if Go is installedgo version
Install on Ubuntu / Debiansudo apt update && sudo apt install golang-go
…without the extrassudo apt install --no-install-recommends golang-go
Install on Fedorasudo dnf install golang
Install the official releasedownload from go.dev/dl, sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go*.linux-amd64.tar.gz
Put it on the PATHexport PATH=$PATH:/usr/local/go/bin in ~/.profile
Verify a downloadsha256sum --check against the checksum on go.dev/dl
See which go runswhich go
See where Go livesgo env GOROOT and go env GOPATH
Test everythinggo mod init hello then go run .

Wrapping up

Installing Go on Linux takes a minute, but the method decides which Go you get:

  • sudo apt install golang-go is the quickest on Ubuntu, but the version is frozen per release: Go 1.22.2 on Ubuntu 24.04, Go 1.18.1 on Ubuntu 22.04.
  • sudo dnf install golang on Fedora gives a recent Go (1.26.10 on Fedora 44).
  • The official download always has the newest Go (1.27.3 in our test): download, verify the checksum, extract to /usr/local/go, add /usr/local/go/bin to PATH.
  • apt's default install is 500 MB because it brings GCC along; --no-install-recommends cuts it to 228 MB.
  • Test with go version and a Hello, World, and use which go when versions look wrong.

Next in this series: how to declare a variable in Go. Just starting? Read Your First Program in Go, and for the bigger picture, What Is the Go Programming Language?

Thanks for reading!

Know someone who would enjoy this? Send it their way.

More articles

Read next

Software & Tools 20 min read

What Is Bash? A Simple Guide to the Bourne Again Shell and the Command Line

A friendly, jargon-free guide to Bash, the program inside the black text window that developers type into. Have a first real conversation with it, see what happens when you press Enter, rename 1,000 photos in under a second and read your first script.

nbkhope

Comments

Be kind and specific. Comments with links from new accounts appear after a moderator reviews them.