How to Install Go on Linux Step by Step Guide

Programming

By Jennifer Webb

Updated on Jul 20, 2026

How to Install Go on Linux Step by Step Guide

Learn how to install Go on Linux using the package manager or the official Go release. Follow simple steps to verify your installation and run your first Go program.

Go is a fast and simple programming language created by Google. It is widely used for web applications, APIs, cloud services, automation, and command line tools.

This guide shows you how to install Go on Linux using both your distribution's package manager and the official Go release. The official release is the best choice if you want the newest version of Go.

Before You Start

Open a terminal and update your system.

Ubuntu and Debian

sudo apt update

Rocky Linux, AlmaLinux, RHEL, and Fedora

sudo dnf check-update

Method 1: Install Go Using the Package Manager

This method is quick and works well for most users.

Ubuntu and Debian

sudo apt install golang-go

Rocky Linux, AlmaLinux, RHEL, and Fedora

sudo dnf install golang

Arch Linux

sudo pacman -S go

openSUSE

sudo zypper install go

After the installation finishes, check the installed version.

go version

You should see output similar to this.

go version go1.xx.x linux/amd64

Package repositories may provide a version that is different from the latest official release.

Method 2: Install the Latest Official Go Release

If you want the newest Go version from the Go team, use this method.

Step 1: Visit the Official Download Page

Open the official Go download page and copy the link for the latest Linux AMD64 archive if your system uses a 64 bit Intel or AMD processor.

The latest stable Go release is currently Go 1.26.5.

Step 2: Download Go

Replace the version in the command below if a newer release is available.

wget https://go.dev/dl/go1.26.5.linux-amd64.tar.gz

Step 3: Remove Any Previous Installation

sudo rm -rf /usr/local/go

Step 4: Extract the Archive

sudo tar -C /usr/local -xzf go1.26.5.linux-amd64.tar.gz

Step 5: Add Go to Your PATH

For Bash users:

echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc
source ~/.bashrc

For Zsh users:

echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.zshrc
source ~/.zshrc

Step 6: Verify the Installation

go version

If the installation was successful, the installed Go version will be displayed.

Create Your First Go Program

Create a new file.

nano hello.go

Paste the following code.

package main

import "fmt"

func main() {
    fmt.Println("Hello, World!")
}

Save the file.

Run the program.

go run hello.go

Output:

Hello, World!

Check Go Environment

To view your Go environment settings, run:

go env

This command displays useful information such as your Go installation path, workspace, and operating system.

Update Go

If you installed Go using your package manager, update it together with the rest of your system.

Ubuntu and Debian

sudo apt update
sudo apt upgrade

Rocky Linux, AlmaLinux, RHEL, and Fedora

sudo dnf upgrade

If you installed Go from the official archive, download the latest release and repeat the installation steps using the new archive.

Uninstall Go

If Go was installed from the official archive, remove it with:

sudo rm -rf /usr/local/go

You can also remove the PATH entry from your shell configuration file if you no longer need it.

If Go was installed using your package manager, remove it with the appropriate command.

Ubuntu and Debian

sudo apt remove golang-go

Rocky Linux, AlmaLinux, RHEL, and Fedora

sudo dnf remove golang

Conclusion

You now have Go installed on your Linux system and are ready to start building applications. Whether you choose the package manager or the official release, you can verify your installation with go version and begin creating Go programs right away. The official installation method is the preferred option when you want the newest features and updates from the Go project.