Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I open a new window in GNU screen, it runs .bashrc but not .bash_profile. In my setup, this results in some environment variables not being set up correctly in that window.

How can I tell GNU screen to always run .bash_profile instead of .bashrc on opening a new window? (Please don't tell me to just call .bash_profile from my .bashrc :)

share|improve this question

You want to start bash (or whatever shell) as a login shell. You do this with

shell -$SHELL

in your ~/.screenrc. The magic is the - before the shell. See man screenrc for details. (Well, not many more details, because that's pretty much it.)

share|improve this answer
Works like a charm. Thank you so much! – Frank V Feb 15 '11 at 16:38

You would either need to source ~/.bash_profile from ~/.bashrc or put the things you need directly into ~/.bashrc or put the things in common in a third file and source it from both your ~/.bashrc and ~/.bash_profile.

share|improve this answer
WHERE to source those ? ... be cuz THAT IS THE PROBLEM (screen do NOT source any of them) – THESorcerer Jul 26 '14 at 7:50
@THESorcerer: On my system, screen sources ~/.bashrc without the shell command shown in the other answer. – Dennis Williamson Jul 26 '14 at 9:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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