Go Command Not Found” Error When Using Sudo - go

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

sudo has its own $PATH which is defined by the secure_path setting in your sudo config.
To fix it:
Open your sudo config sudo visudo
Locate the line staring with Defaults secure_path =
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

Problem with installing Go on Ubuntu 20.04 server

I am new to Ubuntu and am trying to install Go onto my server, however I get an error when trying to use Go.
Command 'go' not found, but can be installed with:
sudo apt install golang-go # version 2:1.13~1ubuntu2, or
sudo apt install gccgo-go # version 2:1.13~1ubuntu2
The commands I used to install Go are below.
$ wget https://dl.google.com/go/go1.15.10.linux-amd64.tar.gz
$ sudo tar -xvf go1.15.10.linux-amd64.tar.gz
$ sudo mv go /usr/local
Then I appended the following to the bash_aliases file.
$ vi ~/.bash_aliases
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
What am I doing wrong here?
I will give you some suggest.
check your path var
echo $PATH
Since you edit ~/.bash_aliases, I think you maybe not source this file.
please try source ~/.bash_aliases.
or try
export $PATH=$PATH:/usr/local/go/bin
beside ~/.bash_aliases may not be load by default. see if . ~/.bash_aliases is in your ~/.bashrc file.
Check if bin can run
/usr/local/go/bin/go version
if have error, maybe is the package you download is wrong. checksum the tar package(for example: md5sum xxxx.tar.gz).
check the default path of go
which go
if go bin not in /usr/local/go/bin/go, you should delete the go bin that shown by which go
Using APT, there is an official package you can install using Ubuntu
Open a terminal and run:
sudo apt update
sudo apt install golang-go
Depending on your version of Ubuntu, you may have to run:
sudo apt install golang
Hope this helps! Its my first answer!

sudo dkms add command issue

I am trying to setup my WIFI adapter settings. I have already run command
sudo apt install git build-essential dkms
when i try to do this
sudo dkms add ./rtlwifi_new
that shows me following error
Error! Could not find module source directory.
Directory: /usr/src/.-rtlwifi_new does not exist.
how I can fix this?
don't run this command in "rtlwifi_new" directory
so back one directory
cd ..

How to update golang on codeanywhere.com with Ubuntu

How to update golang on codeanywhere.com with Ubuntu 14.04?
The default container uses the version from Ubuntu repos, instead of golang PPA.
As of writing it's 1.6 and the newest version is 1.9.
(can't comment yet) Just an additional information, the steps in Paweł Prażak's answer work when you run on a Blank Container. If you run them on a Go predefined stack it won't update.
I also recommend to change the GOPATH value to your workspace, running
export GOPATH=$HOME/go
Then run go env to check if the values are correctly updated.
Thanks for the answer by the way, Paweł!
You can easily install the latest golang release in the container by using this script:
git clone https://github.com/udhos/update-golang
cd update-golang
sudo ./update-golang.sh
Full details: https://github.com/udhos/update-golang
Create and new Blank Container with Ubuntu:
Connect to the container with SSH.
Follow the instructions on the official wiki.
First install the add-apt-repository support:
sudo apt-get update
sudo apt-get install -y software-properties-common
Now install the recent version of golang (refer to the wiki for up to date instructions):
sudo add-apt-repository ppa:gophers/archive
sudo apt-get update
sudo apt-get install golang-1.9-go
Make sure to put the binary on PATH, e.g.:
sudo ln -s /usr/lib/go-1.9/bin/go /usr/local/bin/go
Now the newer version should be available:
$ go version
go version go1.9.2 linux/amd64
Add $GOPATH pointing to the workspace and add $GOPATH/bin to $PATH in ~/.profile:
cat << EOF >> ~/.profile
export GOPATH="\$HOME/workspace"
export PATH="\$GOPATH/bin:\$PATH"
EOF
Apply the new ~/.profile:
. ~/.profile
Also make is missing, if you need it:
sudo apt-get install build-essential

/bin/sh: 1: gvm: not found

Problem:
I'm attempting to create a Dockerfile that installs all the components to run Go, to install GVM (Go Version Management), and to install specific Go Versions.
Error:
When I try building the container with:
docker build -t ##### .
I get this error:
/bin/sh: 1: gvm: not found
The command '/bin/sh -c gvm install go1.4 -B' returned a non-zero code: 127
Installed here:
/root/.gvm/scripts/env/gvm
/root/.gvm/scripts/gvm
/root/.gvm/bin/gvm
What I tried:
It's clearly able to install GVM but unable to use it. Why?
I thought maybe I needed to refresh the .bashrc or the .bash_profile ... but that didn't work, since they don't exist.
Dockerfile:
FROM #####/#####
#Installing Golang dependencies
RUN apt-get -y install curl git mercurial make binutils bison gcc build-essential
#Installing Golang
RUN ["/bin/bash", "-c", "bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)"]
#gvm does not exist here... why?
RUN gvm install go1.4 -B
RUN gvm use go1.4
Question:
Why does GVM not seem to be installed? How do I get rid of the error?
Your shell is /bin/sh, but gvm puts its initialization in ~/.bashrc, and expects /bin/bash.
You need to source the gvm initialization scripts to run the commands from a non-interactive bash shell:
RUN ["/bin/bash", "-c", ". /root/.gvm/scripts/gvm && gvm install go1.4 -B"]
RUN ["/bin/bash", "-c", ". /root/.gvm/scripts/gvm && gvm use go1.4"]
Or even better might be to put the commands you want to execute in a single bash script and add that to the image.
#!/bin/bash
set -e
source /root/.gvm/scripts/gvm
gvm install go1.4
gvm use go1.4

Linux server sudo command not found

I am having Linux server with
2.6.32-673.8.1.lve1.4.3.el6.x86_64 - GNU/Linux
and trying to run following commands :
sudo apt-get update
-bash: sudo: command not found
I have also tried - sudo su
-bash: sudo: command not found
And for lsb_release -a
-bash: lsb_release: command not found
I am trying to install ruby. Any help is highly appreciated.
sudo is in its own package. You probably don't have it installed, so you'll have to login as root and install it.
Sadly, just showing the kernel version doesn't help much, so see if this returns anything: cat /etc/*-release
If it does, you could be using something like CentOS or any other flavor of linux, so apt-get may not work anyway.
Hopefully, you are logging in with root if sudo isn't available. Running whoami should let you know your username if you are not sure.
If you are root, then try (for CentOS) yum install sudo to get sudo or just yum install ruby to install Ruby. If yum is not found, then try apt-get. If that still doesn't work, then you could be using a system with a different package manager (like emerge for Gentoo Linux).
EDIT: Does anything happen if you try /sbin/sudo (or /usr/sbin/sudo)?
Often sudo is not installed by default on distributions like Debian.
Tipe into the console:
su -
After that try to install sudo with this line:
apt-get install sudo -y
To use sudo properly you should give yourself Superuser permissions:
usermod -aG sudo USERNAME
After this step reboot your device and everything should work fine.

Resources