I set a lot of environment variables in my .tcshrc file, using the setenv command.
When I needed to have one of these unset today, I moved this file and opened a new terminal (this is all in a Gnome graphical environment) expecting environment variables I set in my .tcshrc to no longer be in the env.
But some of these variables were still set; where else could they be being set? I know my .login file is empty.

Are setenv commands more global than I think they are? When I open a new virtual terminal via alt-ctrl-F2 the variables were no longer set.


This has to do with sessions and login shells, versus normal shells.

When you start a new session (this is what happens when you log in, either via the virtual terminals or when you start a new desktop session), the login process creates a bare environment, and then your tcsh will be invoked as a login shell and do its startup routine, which includes processing global startup files (like /etc/csh.cshrc) and your .tcshrc file.

So in that case, you're sure to see all your changes.

When you start a "normal" shell (from your desktop environment, or by running tcsh from an existing shell), the environment is not cleaned up and the global files are not processed (but your local profile files are processed).

Since the environment is not cleaned up, your new, normal shell inherits it from its parent (one of your desktop system's processes). That process had read the previous version of your profile files, so it still has the old environment variables set.

You'll see that your changes worked by logging off of your desktop session and logging back in.

See the tcsh man page for exactly what files are processed when.

  • Thanks, the piece I was missing was the invoking tcsh as a login shell when starting a new session when that session is in Gnome - makes sense. – Thomas Oct 7 '11 at 5:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.