Issues setting $PATH on Bash on Ubuntu on Windows (Linux Subsystem)
The direct answer to your problem is at the end. But I think it will make more sense if you keep reading from here.
Before trying to add to PATH
,
I recommend to test a program first.
In your case I would do like this:
wget https://releases.hashicorp.com/terraform/0.9.8/terraform_0.9.8_linux_amd64.zip
unzip terraform_0.9.8_linux_amd64.zip
./terraform
Notice the last line ./terraform
.
The zip file contains a single file, terraform
,
which now should be in the current directory,
so I can run it with ./terraform
.
If it's executable.
If it's not executable then confirm it:
ls -l terraform
And make it executable if needed:
chmod +x terraform
Now let's add it to PATH
.
But first,
let's decide where to put this executable.
/usr/local/bin
seems a reasonable location.
So let's move the terraform
executable into that directory.
Usually /usr/local/bin
is already on PATH
,
so you might not need to change anything.
Now you can try your check, and there's a good chance it already works:
terraform -version
If it doesn't, then /usr/local/bin
is not on the PATH
.
To add it, add this line in ~/.profile
:
export PATH=$PATH:/usr/local/bin
Two things looked fundamentally wrong with your approach:
Adding
/usr/local/terraform
toPATH
. This is fishy, because the entries onPATH
must be directories, and in your post nothing indicates that you created a directory at/usr/local/terraform
.- You
cd
into/usr/local
, and thenunzip
the zip file of terraform. The linked zip contains a single file namedterraform
, so/usr/local/terraform
in your example should be a file. - If it is a file, then you could make it executable as
terraform
by adding to add toPATH
its base directory. But adding/usr/local
toPATH
would not be a good idea. It's conventional to put binaries into/usr/local/bin
, not directly into/usr/local
- You
You did not mention how you reloaded
~/.profile
. After editing this file, the new commands you added do not get automatically executed in your current shell. They will get executed when you open a new shell. Or you could manually execute the added commands in the current shell.