Today I was installing Java Media Framework (JMF) for my project work. I have wasted half of the day to set Environment variables. then I successfully Installed, but JMF is not working as in windows. :( but I Explored more details about Environment Variables in Linux. :)
Environment variables handle or control the flow of running processes in the operating system. Environment variable has a value and a variable which is using some particular application. As a example in Java program, Operating system consist a variable call "PATH" and the value is the path of java's bin directory. Likewise most of the programs (actually running processes) are using Environment Variables for their various types of activities.
We can easily view already stored Environment Variables using Terminal.
- Display Currently defined variable list.
printenv
- Display Currently defined variable list.
echo $PATH (display the program search path)
- using env
- Set Environment variables.
export PATH=$PATH:/usr/java/jdk1.5.0_07/bin
- Erasing Environment Variables.
export PATH=Using above commands you can handle environment variables temporally. If you want to handle Environment Variables Permanently you want to know how they are stored in your architecture.
Environment Variables are stored in two difference ways called Session Specific and System Specific.
1. Session Specific Variables.
These are mostly stored in the specific hidden files/scripts in your home directory. Specially we can identify 3 ways to store Environment Variables.
- ~/.profile
- ~/.bash_profile or ~/.bash_login
- ~/.bashrc
- ~/.bash_logout
These Variables are using whole System and affected all users/sessions in runing time.
- /etc/profile
- /etc/bash.bashrc
- /etc/environment
Finally I'm goint to do a funny work with environment variables.
Just type a command in your terminal.
cool ah? ;) want back?export PS1="\u is a fool$ "
You can do any cool things with PS1 variable. anyway As I said earlier this work is not permanent. close terminal an open back, all settings are restore as earlier.export PS1="\u@\H > "