To set environment variables in Ubuntu:
1) Open /etc/environment file.
This command helps to edit the file: sudo gedit /etc/environment
2) Add your environment variable in /etc/environment file as shown below.
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/SCM/softwares/gradle-2.2.1/bin:/home//SCM/softwares/apache-ant-1.9.4/bin"
3) Restart your machine.
We can also use export command for setting environment variable. To make it permanent we need to include in ~/.bash_profile or ~/.profile or /etc/profile file.
1) Open /etc/environment file.
This command helps to edit the file: sudo gedit /etc/environment
2) Add your environment variable in /etc/environment file as shown below.
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/SCM/softwares/gradle-2.2.1/bin:/home//SCM/softwares/apache-ant-1.9.4/bin"
3) Restart your machine.
We can also use export command for setting environment variable. To make it permanent we need to include in ~/.bash_profile or ~/.profile or /etc/profile file.