Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm trying to integrate RVM with gnome-terminal.

Per default, gnome-terminal does not start bash as a login shell. I enabled run command as a login shell as suggested in this answer about the same topic setting up RVM, but when I do this the .bashrc file is not read.

For example, I create an environment variable in .bashrc and then when I start a new gnome-terminal I cannot read it. I need to run explicitly source .bashrc to read the file.

Is this the expected behavior?

share|improve this question

3 Answers 3

up vote 18 down vote accepted

Yes, that is the expected behaviour.

The behaviour, in short, is as follows:

  • bash started as an interactive login shell: reads ~/.profile
  • bash started as an interactive non-login shell: reads ~/.bashrc

Read the bash manual about startup files for more details.

Personally, I think that this behaviour is strange and I have not yet found a rationalization for this design decision.

Some explanation of the terminology:

  • An interactive shell is a shell with which you can interact, that means you can type commands in it.
  • A non-interactive shell is a shell with which you cannot interact. Shell scripts run inside non-interactive shells.
  • A login shell is the shell which is started when you login to your system.
  • A non-login shell is a shell which is started after the login process. There is an option --login which will make bash behave as if it is a login shell even if started after your have logged in. Configuring gnome-terminal to start bash as a login shell means it will start bash using the --login option.

Most shells you see are interactive non-login shells. This is especially true if you are running a graphical environment like gnome, because then gnome is the "login shell". Any bash session started inside gnome is a non-login shell. If you want to see a real interactive login shell then go to a virtual console (using Ctrl+Alt+F1) and then log in using your username and password. That is a real interactive login bash shell. You can go back to the graphical shell using Ctrl+Alt+F7.

Usually you want bash to always read ~/.bashrc in an interactive shell. Here is how I recommend to do that:

Create a ~/.bash_profile file. If bash is started as a login shell it will first look for ~/.bash_profile before looking for ~/.profile. If bash finds ~/.bash_profile then it will not read ~/.profile.

Put the following lines in ~/.bash_profile:

[ -f "$HOME/.profile" ] && source "$HOME/.profile"
[ -f "$HOME/.bashrc" ] && source "$HOME/.bashrc"

Now if bash is started as an interactive login shell it will read the following files:

  1. ~/.bash_profile
  2. ~/.profile
  3. ~/.bashrc

and if bash is started as an interactive non-login shell:

  1. ~/.bashrc

You should put stuff which is bash specific in ~/.bashrc and stuff which is not bash specific in ~/.profile. For example PATH goes in ~/.profile and HISTCONTROL goes in ~/.bashrc.

Note that ~/.profile is not bash specific. Other text based shells (for example sh or ksh) and graphical shells (gnome) also read ~/.profile. That is why you should not put bash specific stuff in ~/.profile.

share|improve this answer
+1. Thanks, this was driving me up the wall... :-) –  richsage Jun 11 '12 at 20:29
mywiki.wooledge.org/DotFiles explains some history of why it is like it is. The main reason for this issue with rvm though is that rvm puts code, that is meant to be in ~/.bashrc in the first place, in the profile instead. The fault is on rvm. –  geirha Jul 25 '12 at 7:56

I had the same question, and found a solution: Simply use SSH for a real login shell!

1. As superuser, create a dedicated rvm system user for complete isolation, and assign a password:

sudo su

useradd -m rvmuser

passwd rvmuser

2. Install dependencies so that rvm can build rubies without asking for the superuser password:

apt-get install curl gawk libreadline6-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 autoconf libgdbm-dev libncurses5-dev automake bison libffi-dev

3. SSH into localhost for a real login shell (you may have to apt-get install ssh)

ssh rvmuser@localhost

4. Install rvm

\curl -sSL https://get.rvm.io | bash -s stable

5. Log out and back in again so that all rvm functions are loaded


ssh rvmuser@localhost

6. Use rvm :)

share|improve this answer

This is neither a bad design decision, nor a bug, nor an expected behavior of shells and terminals

It is merely an unfortunate default value of a per-profile configuration option in Gnome Terminal, which you can easily fix.

  1. Go to Edit -> Profile Preferences.

  2. Select the Title and Command tab.

  3. Notice how the Run command as login shell checkbox is unchecked! Check it.

That's it. If you do this to the Default profile, or to whatever profile is configured to be used when making new terminals, you get a login shell.

I'm guessing that under the hood, this option probably causes it to pass the -l option to the shell.

share|improve this answer

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.