on trying to configurate go programming language i messed up my PATH in linux. I can not do any commands without specifing the path:

frede@frede-Lenovo-V110-15ISK:~$ ls
Command 'ls' is available in '/bin/ls'
The command could not be located because '/bin' is not included in the PATH environment variable.
ls: command not found
frede@frede-Lenovo-V110-15ISK:~$ echo $PATH

However I can run it with the specified path. I tried to solve this problem at looking at similar threads, but I just couldn't find the solution for me. Can you please help me?


frede@frede-Lenovo-V110-15ISK:~$ grep 'PATH=' ~/.profile ~/.bashrc ~/.bash_profile /etc/profile
/home/frede/.bashrc:export GOPATH=/home/frede/go
/home/frede/.bashrc:export PATH=PATH:/home/frede/go/bin
grep: /home/frede/.bash_profile: No such file or directory
  • 1
    Please edit your question and i) replace the output you show with the output of LC_ALL=C ls, that will give you English error messages; ii) show us the output of grep 'PATH=' ~/.profile ~/.bashrc ~/.bash_profile /etc/profile. – terdon Mar 12 '18 at 11:15
  • Looks like a typo of PATH=PATH... instead of PATH=$PATH... – Jeff Schaller Mar 12 '18 at 11:16
  • 1
    You need to correct this line export PATH=PATH:/home/frede/go/bin in your /home/frede/.bashrc file into export PATH="$PATH":/home/frede/go/bin. – user147505 Mar 12 '18 at 11:51
  • This is a protected file. I tried to vi/vim once and completely messed up a file, so will this do it as well? echo "export PATH=$PATH:/home/frede/go/bin >> ~./bashrc" ? – FrontMobe Mar 12 '18 at 11:54
  • No, that particular line has to be fixed. You can echo, but that line needs to be removed then. – user147505 Mar 12 '18 at 11:56


There should be a right PATH in your /etc/profile. I don't know how you messed up your PATH, but sourcing /etc/profile should bring things back to normal. As long as you didn't edit that one. So try this:

. /etc/profile

Proper PATH setup

Assuming you're using bash, you might make use of .bashrc file (instead of .profile) to setup your path. You can use a similar entry to the one you might find within /etc/profile:

# set PATH so it includes your private Go bin folder if it exists
if [ -d "$HOME/bin" ] ; then

If you aren't using bash, adjust the PATH (same way as above) in your private .profile file instead of .bashrc.

Finally, source the file you've modified:

. ~/.bashrc   # or
. ~/.profile

(note: .profile usually sources .bashrc -- see references for further info)

And if you've polluted some of your files with an erroneous PATH definition, you need to clean that up. Follow Terdon's comment under your question for this.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.