当使用sudo命令时出现“Go Command Not Found”错误。

huangapple go评论159阅读模式
英文:

Go Command Not Found” Error When Using Sudo

问题

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

我尝试使用sudo命令安装工具,但显示sudo: go: command not found....有什么解决办法吗?

但是我已经安装了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

英文:

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

得分: 22

sudo有自己的$PATH,它由sudo配置中的secure_path设置定义。

修复方法:

  1. 打开sudo配置文件 sudo visudo
  2. 找到以Defaults secure_path =开头的行
  3. 在行末尾添加:/usr/local/go/bin

保存配置后,您应该能够使用sudo来运行go命令。

英文:

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

huangapple
  • 本文由 发表于 2022年4月17日 12:47:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/71899341.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定