Change order of PATH variable

October 18, 2016 50 views
Node.js One-Click Install Apps Ubuntu 16.04

I upgraded a one-click node.js ubuntu 14.04 image to ubuntu 16.04.

The default node version is v4.2.1 and it is the old one on my 14.04 image. This old node executable is located on /usr/local/bin/. The newer node which comes with Ubuntu 16 is v4.6 and it is located on /usr/bin. I would like v4.6 to be the default node.js.

In my PATH variable, I discover that /usr/local/bin/ comes before /usr/bin. I think the solution would be to move /usr/bin before /usr/local/bin to use v4.6 as default node.js.

How can I modify PATH variable so that /usr/bin comes before /usr/local/bin? The order needs to be changed.

Thank you.

1 comment
  • THis is how my PATH look like.


1 Answer

You should try writing PATH variable to .bashrc file.
It's located under your home directory, open your with any text editor:

  • nano ~/.bashrc

In try to locate does you have line that begins with:

export PATH=

If you don't have it it in file, feel free to add it.
In your case it should be like

export PATH=/usr/local/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/sbin:/bin:/usr/games:/usr/local/games

Save it and close editor.
You can log out and log in again or use command to refresh it:

  • source ~/.bashrc

Try getting PATH from terminal and see if it is correct.

If you still get problem, maybe you should try removing nodejs package and checking is there node package. Then install by any method you want. If you want better version control, check nvm solution

Have another answer? Share your knowledge.