If you open a GNOME Terminal and navigate @ Edit -> Profile Preferences -> Title and Command, there is a “Run Command as a Login Shell”option which is unchecked -at least on most GNOME Distros.
This can lead in issues that are hard to be tracked by new users that using Linux just to make their work, without want to learn how their system works -which makes perfect sense!
.bashrc Vs .bash_profile
In your $HOME you will find (depending the distros) two hidden files <.bashrc> and <.bash_profile> which are responsible for loading environments, starting -not GUI- programs, define functions, making alias etc, in your GNOME. The difference in quick between these two is that <.bashrc> is the place to put stuff that applies only for bash itself, where <.bash_profile> is the place to put stuff that applies to your whole session.
Many guides in popular applications seems to ignore in their examples/samples that in Linux Distros by default GNOME Terminal doesn’t act as a Login Shell; the examples don’t seem to work and users should Google around to find out what’s the issue.
Hello World Example
Let’s make a typical Hello World GJS Script and try to load it in our environment. In my $HOME:
$ mkdir .jsscripts $ cd .jsscripts $ gedit hello
Print a Hello World in Gnome JavaScript (GJS)
#!/usr/bin/gjs
print("hello world!");
Make it executable
$ chmod +x hello
Now I am gonna add this on $PATH through my <.bash_profile>.
$ gedit ~/.bash_profile
And add in the end of the file
export PATH=$PATH:$HOME/.jsscripts
I now open a new terminal and typing
$ hello
and I am expecting my script to be executed.
What happens is that I if we have “Run Command as a Login Shell” unchecked, Terminal won’t find our script while if we check that, it will normally run it. In this particular example we should had added the script in <.bashrc> and not in <.bash_profile>.
As a rule, system wide environment and startup programs, for login setup go in <.bash_profile>, and functions and aliases go in <.bashrc>.
A Real Example
Lets take as an example the very popular under Linux, RVM (Ruby Version Manager) installation. RVM gets installed under <~/.rvm/bin/rvm> and adds by default (in user-based installation) its environment in <.bash_profile>.
As the above figure shows if we test our RVM installation
$ type rvm | head -n 1
It won’t work if we haven’t set Terminal to run commands as Login Shell. Instead we should source the script
$ source ~/.rvm/bin/rvm
that will work only for the current Terminal, or instead we can source it on our <.bashrc>, so it will work for all Terminal Sessions.
if [ -f ~/.bashrc ]; then . ~/.bashrc fi
<.bash_profile> will be executed for remote SSH and console logins before the initial command prompt, but when you are opening a Terminal from within GNOME Session <.bashrc> is executed before the window command prompt.
I hope that helped, but as always you can get full documentation in The Linux Documentation Project.


