How to set permanent variables


 
Thread Tools Search this Thread
Operating Systems AIX How to set permanent variables
# 1  
Old 08-31-2008
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:
Code:
export VAR=value

# 2  
Old 08-31-2008
This may help:

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

# 3  
Old 08-31-2008
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
# 4  
Old 08-31-2008
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! Smilie
# 5  
Old 08-31-2008
You're welcome!

Smilie
# 6  
Old 08-31-2008
Quote:
Originally Posted by agasamapetilon
I decided to create a .profile document...
document insinuates you are coming from Windows?Smilie
$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.
# 7  
Old 08-31-2008
You made it even more clear to me with your explanation Smilie I checked and the login shell I have is Korn shell.

Code:
/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?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to set variable permanent in csh?

We are using csh on our AIX platform, if we have to export/set a specific environment variable we use setenv command but its only valid till session. How do we set that variable permanent in our csh AIX? Do we put it in userprofile file or something else? (1 Reply)
Discussion started by: aixusrsys
1 Replies

2. Shell Programming and Scripting

How to set a variable name from another variables value?

Experts, I want to set value of variables like this in bash shell: i=5 ; L=100 I want variable d5 (that is d(i) ) to be assign the value of $L , d$i=$L ; echo $d5 Not working Thanks., (3 Replies)
Discussion started by: rveri
3 Replies

3. Solaris

How to set permanent aliases?

Hi All On my Solaris 10 X86, under my root directory I have a file called Aliases. It is owned by root (root:root) and the user (I mean root) has rwx permissions. In this file I have set some aliases like the following alias a="cd /opt/IBM/WebSphere/AppAerver/Profiles" When I run the above... (0 Replies)
Discussion started by: chrs0302
0 Replies

4. Shell Programming and Scripting

Need to SET Environment variables

Hi Could you please tell me how to set environment variables in Unix ksh. And how can acess those varibles in shell scripts ( Please give the code with an example) For my scenario. We have written number of shell scripts with hard coded username and password. But if we want to... (1 Reply)
Discussion started by: shyamu544
1 Replies

5. HP-UX

set permanent ulimit

Hi all I have a request from user to change the file descriptors limit to 8192. The current setting are: root@xxxxx:(wmdev)> ulimit -a time(seconds) unlimited file(blocks) unlimited data(kbytes) 1048576 stack(kbytes) 131072 memory(kbytes) unlimited... (3 Replies)
Discussion started by: hedkandi
3 Replies

6. Solaris

Solaris 9 -- unable to set permanent PATH

Hi, I've read forums far and wide trying to learn how to append to my PATH in Solaris 9 and every time I think I am close I discover my system is not configured the same. Its so frustrating because this all stems from a new server I am trying to setup identical to the production machine. (Of... (5 Replies)
Discussion started by: thoraddict
5 Replies

7. UNIX for Dummies Questions & Answers

SET Command removed the variables

Hi, Im using csh and sometimes bash. I accidentally typed SET and looks like it has resetted some enviroment variables as im not able to run autosys jobs etc .. So i wanted to know how i can put it back to normal by replacing any profile files from another user or by editing the file which... (2 Replies)
Discussion started by: spectator
2 Replies

8. UNIX for Advanced & Expert Users

by using c++ how to set environment variables in unix

hi, I am writing c++ code in unix operating system.In that i need to set the environment variable in unix. suppose previously i have environment variable like path="something" now i need to change the path value to some othervalue . so that some other program will access that path value... (1 Reply)
Discussion started by: sada@123
1 Replies

9. UNIX for Dummies Questions & Answers

Using Variables to Set Other Variables

I have a script that I'm trying to shorten (below) by removing repetitive code. if ] then commodity_ndm_done=Y fi if ] then customer_ndm_done=Y fi if ] then department_ndm_done=Y fi if ] then division_ndm_done=Y fi (3 Replies)
Discussion started by: superdelic
3 Replies

10. Shell Programming and Scripting

How do I set permanent setenv !!!

Hello, I just want to know ow I can set permanent pathes or whatever using setenv command. I'm using c shell . regards, me (1 Reply)
Discussion started by: geoquest
1 Replies
Login or Register to Ask a Question