Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Go Command Not Found” Error When Using Sudo

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

like image 972
zerinx Avatar asked Dec 20 '25 10:12

zerinx


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

like image 183
Dylan Reimerink Avatar answered Dec 23 '25 04:12

Dylan Reimerink