0

I'm a newbie to Ubuntu. I want to add some variables to my PATH - I am using the following steps:

  1. Open a terminal window.

  2. Type the following commands:

    export GOROOT=/home/linux/go/hg
    export GOOS=linux
    export GOARCH=386
    export GOBIN=/home/linux/go/bin
    export PATH=$PATH:$GOBIN
    

When I type the following command in a terminal window:

env | grep '^GO'

It shows:

GOBIN=/home/linux/go/bin/
GOARCH=386
GOROOT=/home/linux/go/hg
GOOS=linux

I have tried the following command in a terminal window:

gedit ~/.bashrc

and pasted the following lines at the end of the file:

GOROOT=/home/linux/go/hg
GOOS=linux
GOARCH=386
GOBIN=/home/linux/go/bin

The problem is that env is not showing the above mentioned variables in PATH. Perhaps I am using the wrong command to store the paths, or storing my path variables in the wrong file?

Can someone guide me where and how to store the above mentioned variables in the PATH permanently?

3 Answers 3

5

You forgot to export them. Edit your ~/.bashrc to something like this:

export GOROOT=/home/linux/go/hg
export GOOS=linux
export GOARCH=386
export GOBIN=/home/linux/go/bin

If you want the GOBIN available in your search paths, append this line too:

export PATH=$PATH:$GOBIN
1

I believe you need to export the variables in .bashrc as well. Also, you might need to source .bashrc or log out and back in again.

1
  1. Put export before the variables in your .bashrc.
  2. Save the file.
  3. Log in and out / Open new terminal.
  4. Try for example env | grep 'PATH' and your path will show up.
3
  • The env | grep '^GO' is 100% valid regarding to what the op wanted to do.
    – shinkou
    Jun 29, 2011 at 5:21
  • Yes, and for that I edited my answer even before your comment.
    – Franz
    Jun 29, 2011 at 5:34
  • Sorry, but my browser didn't reload. :P
    – shinkou
    Jun 29, 2011 at 5:36

You must log in to answer this question.