How to set permanent variables

I set my TERM variable to work with SMIT and everything works fine but when I logged out and log in again I have to set the variable again.

How can I set a permanent variable into the system so it will be as I wish even if a reboot is needed?

I set variables this way:

export VAR=value

This may help:

printf "TERM=value; export TERM\n" >> "$HOME/.${SHELL##*/}rc"

Hi,
depending on the shell You use (i.e the command interpreter, bash/sh/ksh/zsh) You should have a file in Your home directory called .bashrc, .kshrc, or something similar. Even .profile. If You have it, put the command there. Then it will be in effect every time You log in.

/Lakris

Thanks to both of you guys, those answers were just what I needed. I decided to create a .profile document and export right there the variables I need, so at the login they will be executed in the users session.

Thanks! :slight_smile:

You're welcome!

:slight_smile:

document insinuates you are coming from Windows?:rolleyes:
$HOME/.profile is exactly the right file where one would set its environment for Bourne Shell compatible login shells,
while the also mentioned $HOME/.shrc file by convention usually holds shell alias and function definitions.
Not to confuse you, but beware. If your login shell was bash and there was a .bash_profile in your $HOME,
then Bash would rather read its contents.
So it is always advisable to consult the man page of the respective login shell one uses,
and especially the FILES section therein.
However, for Bourne compatible shells, .profile is the common denominator.

You made it even more clear to me with your explanation :slight_smile: I checked and the login shell I have is Korn shell.

/usr/bin/ksh

Is the Korn shell compatible with Bash? I make this question because I created the .profile and I want no problems with it. I made a check also at $HOME/ and I only have: .profile (the one I created), .vi_history and .sh_history but no more of the likes of $HOME/.shrc that you mentioned. Should I create a file for this specific shell?

I think the correct answer is that bash and korn are compatible with sh (the Bourne Shell), a kind of reference/standard/basic shell.
And the ~/.profile is the correct place to put a command You want to have executed each time You start a new shell, for example when You log in.
This will be read by all sh-compatible shells. As a contrast, if You have a .bashrc, it will only be read by Bash, not ksh (Korn) and so on.

/Lakris