Go Command Not Found” Error When Using Sudo

Viewed 2656

sudo go install github.com/KathanP19/Gxss@latest sudo: go: command not found

I try to install tool with sudo command but it shows sudo: go: command not found....any solutions?

but i installed go

─(spark㉿usr)-[~] └─$ go version 1 ⨯ go version go1.18.1 linux/amd64

echo $PATH
/home/spark/.cargo/bin:/home/spark/.local/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/go/bin

1 Answers

sudo has its own $PATH which is defined by the secure_path setting in your sudo config.

To fix it:

  1. Open your sudo config sudo visudo
  2. Locate the line staring with Defaults secure_path =
  3. Add :/usr/local/go/bin to the end of the line

After saving the config, you should be able to use go with sudo

Related