Back to .md Directory

🦫 Installing Go and Go-Based Tools (like `hakrevdns`) on Linux

Walks through installing Go on Linux and using `go install` to build tools like `hakrevdns`, then moving them to a system-wide PATH.

May 2, 2026
0 downloads
0 views
ai
View source

What this file does

Walks through installing Go on Linux and using go install to build tools like hakrevdns, then moving them to a system-wide PATH.

When to use it

  • Setting up a fresh Linux pentesting or development environment
  • Installing Go-based security tools like httpx or subfinder
  • Learning how Go separates compiler files from user-installed binaries
  • Automating global tool installation with a shell function

Assumes this stack

GoLinuxZshBash

🦫 Installing Go and Go-Based Tools (like hakrevdns) on Linux

🧭 Step 1: Check if Go is Installed

go version

If it says command not found, continue below.


🧩 Step 2: Download and Install Go

Visit the official Go download page: šŸ‘‰ https://go.dev/dl/

Then download the latest Linux tarball, for example:

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

Remove any old installation:

sudo rm -rf /usr/local/go

Extract it to /usr/local:

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

āš™ļø Step 3: Add Go to Your PATH

If you use Zsh (default on Kali, Parrot, etc.):

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

If you use Bash:

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

Check Go version:

go version

āœ… Should print something like go version go1.23.2 linux/amd64


🧠 Understanding Go's Folder Structure

It’s important to understand how Go separates its compiler from user-installed tools:

LocationPurposeOwner
/usr/local/goGo compiler & standard libraryRoot/system
~/go/binWhere Go installs new tools (like httpx, hakrevdns, etc.)Your user
/usr/local/binWhere you can move tools to make them globally availableRoot/system

šŸ” Explanation

  • /usr/local/go → contains the Go runtime and compiler. You should not install tools here.
  • ~/go/bin → Go automatically puts new binaries here when you run go install ....
  • /usr/local/bin → already in your PATH system-wide, so moving tools here makes them available everywhere.

Even though Go is installed in /usr/local/go, your tools are still built under ~/go/bin by default. This design keeps system files separate from user data.

If you want your tools to be globally accessible, you can manually move them:

sudo mv ~/go/bin/hakrevdns /usr/local/bin/

Now you can run it from anywhere:

hakrevdns -h

🧰 Step 4: Install a Go Tool (Example: hakrevdns)

Method 1 — Regular Install (Default Behavior)

go install github.com/hakluke/hakrevdns@latest

This builds the binary in:

~/go/bin/hakrevdns

Move it globally:

sudo mv ~/go/bin/hakrevdns /usr/local/bin/

Test:

hakrevdns -h

Method 2 — Automated Helper Function (Optional)

Add this function to your ~/.zshrc:

goinstall() {
    go install "$1"
    tool=$(basename "$1" | cut -d'@' -f1)
    sudo mv ~/go/bin/$tool /usr/local/bin/ 2>/dev/null
    echo "$tool installed globally."
}

Reload your shell:

source ~/.zshrc

Now install globally in one line:

goinstall github.com/hakluke/hakrevdns@latest

āœ… Output example:

hakrevdns installed globally.

🧠 Notes

  • /usr/local/go/bin → Go compiler
  • ~/go/bin → Build output for tools
  • /usr/local/bin → Global tools location

šŸ” Verify

which go
which hakrevdns

Both should show paths under /usr/local/.


āœ… Example Summary

TaskCommand
Install Gosudo tar -C /usr/local -xzf go1.23.2.linux-amd64.tar.gz
Add PATHexport PATH=$PATH:/usr/local/go/bin
Install toolgo install github.com/hakluke/hakrevdns@latest
Move globallysudo mv ~/go/bin/hakrevdns /usr/local/bin/

What's inside

5 steps, 2 installation methods, 1 optional helper function, 1 comparison table, 1 summary table

Change this for your project

  • Replace go1.23.2.linux-amd64.tar.gz with the latest Go version URL
  • Replace github.com/hakluke/hakrevdns with the tool you want to install
  • Replace ~/.zshrc with ~/.bashrc if you use Bash

Where it goes

A standard operating procedure. Keep where the team or agent running the process will find it.

Worth borrowing

  • Using a shell function to combine go install and sudo mv into one command
  • Explaining the three key directories and their ownership to demystify Go's layout

Related Documents