go command not working if I switch to super user in zsh shell ..i even updated the zshrc file ...anyone who knows solution to problem please explain in detail..I'm new to linux
Asked
Active
Viewed 441 times
1
-
Why would you ever want to run `go` as root? The root user has a separate shell with separate shell initialization files. Setting `PATH` for your ordinary user will not update the path for the root user. Did you fix the path for root too? – Kusalananda Apr 27 '21 at 13:05
-
Please [edit] your question and show all code and output as text in your question, formatted as code blocks. You are using Kali Linux, which is a specialized distribution intended to be used by experts, but your question is merely beginner level. It might be easier to use a Linux distribution which is intended for general use and install `go` from your distribution's package repository. – Bodo Apr 27 '21 at 13:07
-
@Kusalananda `go get -u github.com/xxxxx/xxxxx` & `cd $GOPATH/src/github.com/xxxxx/xxxxxx/` If I want to use th `cd` command I want to be a root user then it works,otherwise it is not working..so what is the solution ..how do I solve this issue – Durai Murugan Apr 27 '21 at 13:16
1 Answers
0
Use sudo -E to pass your PATH environment variable to your root session.
The root user does not know about your updated PATH variable, which your standard user account has adjusted in your shell configuration. If you use -E with sudo it will pass the environment variables to sudo.
Mike Mackintosh
- 111
- 3
-
If I use this ```sudo -e PATH=$PATH:$GOROOT/bin/:$GOPATH/bin``` command I get an error saying ```sudo: you may not specify environment variables in edit mode``` – Durai Murugan May 03 '21 at 10:27
-
`PATH=$PATH:$GOROOT/bin/:$GOPATH/bin sudo -E` its case sensitive – Mike Mackintosh May 06 '21 at 06:08
