Tuesday, April 19, 2011

Changing system variables permanently

I wanted to change the the system variable $PATH in a such a way that bash executes scripts in current working directory. I can do this simply by PATH="$PATH:.". While working on this I came to know about following things....

You can change the value of system variables simply by doing sys_var_name="new_value". But such a kind of initialization is only temporary. Once you close the terminal the system variables you changed is reset to old values. So we have to initialize the system variables for our convenience every time we launch the terminal. Doing it manually is really boring. So is there any way to do it automatically?
The answer is a big ΥΕS. '.bashrc' is a shell script that's executed every time at the  launch of terminal. '.bashrc' is kept in the users home folder. You can edit .bashrc script in a such a way that it edits system variable automatically for your convenience every time you launch the terminal. Thus you can change the system variables permanently. You can even run shell scripts of your choice at the launch of terminal automatically by editing .bashrc :-) 

No comments:

Post a Comment