how to set environment variables that i use everyday permanently
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
how to set environment variables that i use everyday permanently
Hi All,
I have bunch of environment variables that i have to set always for my work.Someone mentioned i can write a script to dp this and i googled it but haven't been successful so far and have to manually do them every time.
I have a tcsh shell.I read that i need to change the .login or .tcshrc files but havent been successful in finding these.Can someone please provide me some information i could use to do this?
Yes, you can put your own setenv statements either in $HOME/.login or in $HOME/.tcshrc. These are hidden files under your HOME directory: you can check if they already exist by means of:
Code:
ls -a $HOME/.tcshrc $HOME/.login
If not you can create them and add code at your pleasure. The file .tcshrc will be read by every shell upon starting a new shell session. The file .login will be read by every login shell after .tcshrc. See man tcsh (section FILES) for details.
Hi All,
I have bunch of environment variables that i have to set always for my work.Someone mentioned i can write a script to dp this and i googled it but haven't been successful so far and have to manually do them every time.
I have a tcsh shell.I read that i need to change the .login or .tcshrc files but havent been successful in finding these.Can someone please provide me some information i could use to do this?
in Bash you'd put them in ~/.bash_profile or /etc/profile for globally used ones.
Otherwise echo your setenv (or whatever applies to that shell) to a script and run the singular script. If you're in X, you could make it part of the terminal launch to run script and persist. Or use whatever ~/.??? applies to your preferred shell. Many means.
I have the Red Hat Enterprise Linux Client release 5.5 version.
I issued ls -a in my directory(/local/home/my_user_name) but the .cshrc and .login file do not exist so i created a login file and wrote all the env varaibles:
so i created a login file and wrote all the env varaibles
Which file did you create? Better to stick with $HOME/.tcshrc which should be read both by interactive and non-interactive shells. Also, please post the output of
I even added #!bin/bash as the first line in the .tcshrc file.
Well.. nope. Since the login shell is /bin/tcsh and you use the setenv command it should give an error.
Anyway, it is a strange problem since the parsing (and sourcing) of the $HOME/.tcshrc file is hard-coded in the tcsh binary executable. Please, can you show us the actual content of $HOME/.tcshrc and the output of
A lot of the variables are inherited from the parent shell. So unless you completely logged out at the highest level, it might not be taking effect. Once set a reboot should apply it at the highest level, but you don't have to do that with linux. If you login at a console, and still need to set them manually, you might try setting them then su - (yourself). Then launch X or whatever environment suits. That should ensure inheritance to child processes.
Various shells have different syntax's for setting environment variables. set, setenv, export and other means in other shells. Make sure that you're using what's appropriate for your shell. While most have similar syntax's, they're not always interchangeable. According the tcsh's manpage printenv, setenv, unsetenv are the methods employed for it.
are files of interest. With a whole lot of if this one isn't, then try here. Which implies, if this one IS here, then ignore that one. At a minimum any scripts in it should deploy a she bang of
!#/usr/bin/tcsh
or
!#/bin/tcsh
with or without /local/ depending on your distro and/or install method.
But I haven't actually used tcsh, so I could be wrong. Spelling correction at the cli seems intriguing though.
According to my shell these commands seem appropriate yet they are not set when i login.
Yes, the syntax is very simple and absolutely correct. What about
Code:
ls -al $HOME/.tcshrc
? At this point it would be useful to know how do you login (graphical login, remote shell, by means of the su command and so on) even if the .tcshrc file should be sourced by every shell type.
Finally, please can you try to verify the tcsh package?
Yes i think it has something to do with the way i login.Its a university system with multiple user levels.I login remotely using ssh.
When i do: "ls -al $HOME/.tcshrc" - it says no such file.But its not at $HOME that is my working directory. Its /local/home/djain and its here that i have written a .tcshrc file which i think now is not the correct place to put it.
What if i write a simple script lets say myscript.sh in my working directory and write the same commands in it:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.