Wednesday, December 12, 2007

Changing Environmental Variables

It's really handy to be able to change the way your shell works for you. Being able to add aliases, and other options makes the shell a much more powerful tool. Changing or setting environmental variables is done differently for each shell.

To change an environment variable in csh or tcsh use:$ setenv NAME "value"where NAME is the name of the variable and "value" its new value.

To change an environment variable in /bin/sh use:
$ VARIABLE="value"
$ export VARIABLE

You can permanently set environment variables for your shell by putting them in a startup file for the shell. The name of the startup file varies depending on the shell;
csh and tcsh uses .login,
bash, sh, ksh and zsh use .profile.
When using bash, sh, ksh or zsh, don't forget to export the variable.

*Note:
.login and .profile are to set conditions which apply to the whole session and to perform actions that are relevant only at login.

.cshrc and .shrc are used to set conditions and perform actions specific to the shell and to each invocation of it.
The guidelines are to set ENVIRONMENT variables in the .login, .profile file and SHELL variables in the .cshrc, .shrc files.

3 comments:

Anonymous said...

Thanks mate for the information http://www.pricelessweddings.com.au

Anonymous said...

http://www.pricelessweddings.com.au

graham said...

I recently came accross your blog and have been reading along. I thought I would leave my first comment. I don't know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often.


Joyce

http://www.shunmigraine.com