---
title: "How to Install GO on Ubuntu Linux"
description: "Learn the ins-and-outs of how to install GO on Ubuntu Linux and see how you can take advantage of this popular programming language!"
canonical: "https://adamtheautomator.com/install-go-on-ubuntu/"
---

# How to Install GO on Ubuntu Linux

> Learn the ins-and-outs of how to install GO on Ubuntu Linux and see how you can take advantage of this popular programming language!

Source: https://adamtheautomator.com/install-go-on-ubuntu/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![How to Install GO on Ubuntu Linux](https://adamtheautomator.com/wp-content/uploads/2023/08/install-go-on-ubuntu-1.jpg)

# How to Install GO on Ubuntu Linux

[![](https://secure.gravatar.com/avatar/2788bb1a3f735603f81eca51d68daec56a9d97e805a10268fb2c20afcc76b81b?s=192&d=mm&r=g)Nicholas Xuan Nguyen](https://adamtheautomator.com/author/nicholas-xuan-nguyen/)16 August 20236 min. read

Categories: [IT Ops](/category/it-ops/)

Tags:[Linux](/tag/linux/)[Ubuntu Linux](/tag/ubuntu-linux/)

Table of Contents

*   [Prerequisites](#prerequisites)
*   [Enforcing the APT Package Manager to Install Go on Ubuntu](#enforcing-the-apt-package-manager-to-install-go-on-ubuntu)
*   [Installing Go via the Latest Binary Release](#installing-go-via-the-latest-binary-release)
*   [Creating a Project to Test the Go Framework](#creating-a-project-to-test-the-go-framework)
*   [Conclusion](#conclusion)

Modern technology has made developing and managing your applications with the help of various frameworks, like Go (Golang), easier than ever. But would you like to fill in that curiosity? Why not install Go on Ubuntu? Worry not; this tutorial got you covered!

Go allows developers like yourself to write reliable code quickly and efficiently. And in this tutorial, you will learn to install Go on Ubuntu and compile a Go program to test your Go framework.

Read on and develop your Go environment today!

## Prerequisites

Below are a few things you need in place before taking advantage of Go:

*   An Ubuntu system with at least version 18.04 or higher – This tutorial uses Ubuntu 20.04.

Related:[How to Install Ubuntu 20.04 \[Step-by-Step\]](https://adamtheautomator.com/install-ubuntu/)

*   A user account with sudo rights on your Ubuntu system.

Related:[How to Create Users on Ubuntu Linux in Multiple Ways](https://adamtheautomator.com/create-user-on-ubuntu/)

## Enforcing the APT Package Manager to Install Go on Ubuntu

Being an open-source programming language, Go has quickly become prevalent among developers. Besides downsizing compile time of programs, you can use Go for various applications, whether for cloud or server-side applications or AI and robotics.

But like any other language, you must install Go on your system. In this case, you will first install Go via the APT package manager. This approach facilitates Go’s direct download and installation from Ubuntu’s official repositories.

To install Go on your Ubuntu, follow these steps:

1\. Open your terminal, and run the [`apt update`](https://linuxize.com/post/how-to-use-apt-command/#updating-package-index-apt-update) command below to update the APT package repository to ensure the latest versions of packages are available.

```bash
sudo apt update -y
```

![Updating the APT package repository](https://adamtheautomator.com/wp-content/uploads/2023/08/image-160.png)

Updating the APT package repository

Related:[Learning Ubuntu Apt Get Through Examples](https://adamtheautomator.com/ubuntu-apt-get/)

2\. Next, execute the following command to download and `install` Go (`golang`) from Ubuntu’s package repository.

```bash
sudo apt install golang -y
```

![Installing Go on Ubuntu via the APT package manager](https://adamtheautomator.com/wp-content/uploads/2023/08/image-161.png)

Installing Go on Ubuntu via the APT package manager

3\. Lastly, run the below command to verify Go is successfully installed by checking its version.

```bash
go --version
```

You will see the installed Go version below, confirming that the installation was successful.

![Checking the GO version](https://adamtheautomator.com/wp-content/uploads/2023/08/image-162.png)

Checking the GO version

## Installing Go via the Latest Binary Release

Although the apt package manager simplifies Go’s installation process, it may not always provide the most up-to-date version. Another method to install Go is by installing its binary directory from Golang’s website, which ensures access to Go’s latest release.

Go’s binary is a pre-compiled version of the Go compiler and runtime environment. This compiled binary can be executed on your specific system without compiling the Go source code yourself.

To install Go via its binary:

1\. Open your preferred web browser, and head over to the [Golang website](https://go.dev/dl/).

2\. Next, look for the version compatible with your Ubuntu machine, and copy the download link for your system’s architecture and the hash value.

At this time of writing, the latest version for 64-bit Ubuntu machines is **go1.21.0.linux-amd64.tar.gz.**

![Copying the download link of Go’s binary](https://adamtheautomator.com/wp-content/uploads/2023/08/image-167.png)

Copying the download link of Go’s binary

3\. Now, run the below `wget` command to download the binary to your working directory. Ensure you replace the URL below with the one you copied in step two.

```bash
sudo wget https://go.dev/dl/go1.21.0.linux-amd64.tar.gz
```

![Downloading Go’s binary](https://adamtheautomator.com/wp-content/uploads/2023/08/image-166.png)

Downloading Go’s binary

4\. Once downloaded, execute the following `sha256sum` command to verify the file’s (`go1.21.0.linux-amd64.tar.gz`) integrity.

Checking the hash value of the downloaded package helps ensure that the file has not been maliciously modified or corrupted during transit.

```bash
sudo sha256sum go1.21.0.linux-amd64.tar.gz
```

Compare the hash value in the output below with the one you noted in step two. If both hash value match, your file is intact. Otherwise, you must re-download the binary.

![Checking the binary’s integrity](https://adamtheautomator.com/wp-content/uploads/2023/08/image-165.png)

Checking the binary’s integrity

5\. Now, run the below command to extract the contents of the downloaded binary (`go1.21.0.linux-amd64.tar.gz`) into the `/usr/local/` directory.

This command does not provide output to the terminal but unpacks the archived files and directories, making them accessible and usable on your system.

After extraction, the Go executable files, like the compiler and other Go tools, are located in the `bin` subdirectory of `/usr/local/go/`.

```bash
sudo tar -xzf go1.21.0.linux-amd64.tar.gz -C /usr/local/
```

6\. Open the _~/.profile_ file in your preferred editor. This file is a system-wide configuration file that sets environment variables for your users on the system.

Related:[How To Wrangle Ubuntu Environment Variables](https://adamtheautomator.com/ubuntu-environment-variables/)

7\. Next, add the following line at the bottom of the _~/.profile_ file, save the changes, and close the editor.

This line modifies the `PATH` variable to include the `bin` directory of your Go installation. This modification lets you run Go commands from any terminal window without specifying the Go executable’s full path.

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

![Editing the ~/.profile file](https://adamtheautomator.com/wp-content/uploads/2023/08/image-164.png)

Editing the ~/.profile file

8\. Execute the below `source` command to update your system’s environment variables with the new `$PATH` setting.

This command has no terminal output but applies your changes to the `~/.profile` file into the current shell session.

```bash
source ~/.profile
```

9\. Finally, run the following `go` command to verify that Go is correctly installed.

```bash
go version
```

If all goes well, you will see Go’s version installed, which should match Go’s binary version you downloaded in step three (**go1.21**).

![Verifying the Go is correctly installed](https://adamtheautomator.com/wp-content/uploads/2023/08/image-162.png)

Verifying the Go is correctly installed

## Creating a Project to Test the Go Framework

Post-installation, you must take a crucial step to ensure the Go framework on your system is in force. How? In this example, you will create and run a basic Hello World program to ensure your GO installation works correctly.

1\. Execute the following command to create (`mkdir`) and move (`cd`) to a new Go project directory named `my-go-project` (arbitrary). This directory is where you will create and save all your GO source code and program.

```bash
mkdir my-go-project && cd my-go-project
```

![Creating a new Go project directory](https://adamtheautomator.com/wp-content/uploads/2023/08/image-171.png)

Creating a new Go project directory

2\. Next, run the `go` command below to initialize (`init`) a module (`mod`) for your Go project. A module is a collection of Go packages that are versioned together.

Go introduced a “Go modules” feature to manage dependencies and versioning within projects. This feature allows you to manage your project’s dependencies more effectively and ensures your project clearly understands the dependencies it requires.

The `ata.com/hello` argument is the module path, typically a URL-like path uniquely identifying your module. Change this module path with the import path of your project or a custom path that suits your organization or project structure.

```bash
go mod init ata.com/hello
```

![Initializing a module for your project](https://adamtheautomator.com/wp-content/uploads/2023/08/image-168.png)

Initializing a module for your project

3\. With a module initialized, create a source code file named `hello.go` with your preferred editor, add the following code to the file, and save it.

The code below is a program that demonstrates the basic structure of a Go program and prints a message to your terminal.

```go
// Define the package name, a collection of related functions, variables, and types.
package main
// Import the fmt package for input and output operations.
import "fmt"
// The main function - starting point of the program's execution.
func main() {
    // Print a message to the terminal and move the cursor to the next line.
    fmt.Printf("Hello world! This is my first GO program\n")
}
```

> 💡 _Even though modeled after the C programming language, Go was inspired by Python’s productivity and relative simplicity._

4\. Now, run the following command to `build` (compile) your source file and create a binary file with the same name as your source file (_hello_).

This command tells Go to read your source code, resolve imports, check for errors, and generate machine code for the specified source file. The result is an executable binary file you can run on your system.

Compiling your source code into an executable binary makes sharing your program with others easier without sharing the original source code. Moreover, the compiled binary file runs independently on compatible systems.

```bash
go build
```

If no errors are found, the command does not provide output to the terminal, as shown below.

![Compiling the source code](https://adamtheautomator.com/wp-content/uploads/2023/08/image-170.png)

Compiling the source code

5\. Finally, execute the command below to run the binary file (_`hello`_), which starts your program and executes the code written inside the `main` function.

```bash
./hello
```

Successfully running the program prints the message below to your terminal, which confirms your Go installation is working correctly.

Congratulations! You have successfully written and compiled your first Go program on Ubuntu.

![Running the Go program](https://adamtheautomator.com/wp-content/uploads/2023/08/image-169.png)

Running the Go program

## Conclusion

Throughout this tutorial, you learned how to install Go on your Ubuntu machine and compile your first Go program. You can now take advantage of Go’s powerful features and performance and develop your Go applications.

Now, why not enhance collaboration by using version control systems like [Git](https://adamtheautomator.com/git-and-remove-from-commit/) to monitor changes in your Go project? Take your Go knowledge further; explore the [official documentation](https://go.dev/doc/) and additional resources available!

Related:[Save the Day With Git and Remove From Commit History](https://adamtheautomator.com/git-and-remove-from-commit/)

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Finstall-go-on-ubuntu%2F&text=How%20to%20Install%20GO%20on%20Ubuntu%20Linux)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Finstall-go-on-ubuntu%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Finstall-go-on-ubuntu%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/2024/03/openldap-4.jpg)

### [How to Install and Configure an OpenLDAP Ubuntu Server](/openldap/)

Unlock the power of OpenLDAP on Ubuntu for centralized user authentication, seamless access control management, and enhanced directory services!

![](https://adamtheautomator.com/wp-content/uploads/2023/07/update-the-kernel-in-ubuntu.jpg)

### [Learn how to Update the Kernel In Ubuntu Linux Safely](/update-the-kernel-in-ubuntu/)

In this ATA Learning tutorial learn the ins-and-outs to update the kernel in Ubuntu Linux safely through several different methods!

![](https://adamtheautomator.com/wp-content/uploads/2023/04/upgrade-ubuntu.jpg)

### [How to Upgrade Ubuntu Linux to a New Release](/upgrade-ubuntu/)

Learn how to easily upgrade Ubuntu to the latest release. Also known as a distribution upgrade, learn how to tackle the upgrade in this ATA Learning tutorial!

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
