Change order of PATH variable

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.

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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

  1. 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:

  1. 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