Jar Bar guide to set a Linux PATH environment variable by Yucca Nel
Linux systems such as Ubuntu are more flexible than Windows for doing tasks like adding or modifying the PATH environment variable. This a a very brief guide demonstrating how to modify Linux environment variables with 'nano' in the terminal. Take special note of the following: 1)You should keep the existing PATH values as they are. Doing so might save you from a few tasks as there are many applications that are already discoverable and defined in the PATH. Ubuntu provides many tools out the box, but there seem to always be some that are outdated, so knowing how to set environment variables such as the PATH are good to know, 2)You can easily set environment variables at any time from the terminal client. This can be done in two ways. You can use 'nano' to access the environment file and modify these values permanently, or you can simply modify them in the terminal for what is referred to as a session. In such a scenario the variable is only scoped for as long as the terminal client remains open and is lost as soon as the client application is closed or if the system is shut down.
Open an Ubuntu or other Linux terminal
You can define any environment variable in the terminal as follows. If the variable exists, it is overwritten. If not, it is created, but only lasts for the session PATH=[value here]
Overwrite the your Linux PATH
It is possible to overwrite your PATH without losing the existing values as follows. This uses the existing variable by accessing it with the dollar($) sign and name and then appending to it. To append, we separate existing values and new values with a colon(:) and not a semicolon(;) like on Windows.PATH=$PATH:JAVA_HOME/bin:M2_HOME/bin
Setting your PATH permanently
It makes far more sense to define environment variables permanently. To do so, write anything you would do in the /etc/environment file instead using nano /etc/environment/ or gedit/etc/environment and appending to the file. Then you must either reboot your system or 'source the file through the source /etc/environment to tell update the values being used in your terminal.