Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

I added some lines to my ~/.bashrc like

export JAVA_HOME=/opt/jdk1.6.0_22

I sourced it:

$ source ~/.bashrc
$ env | grep 'JAVA'

Then I created a basic bash script under a folder called scripts in my home:


echo 'start'
echo $(env | grep HOME)
echo $(env | grep LOGNAME)
echo $(env | grep JAVA)
echo 'exiting'

sleep 5

Now, if I launch it directly I get the expected output

$ cd ~/scripts
$ bash ''

However I need to call it in a different way using the following command, and unluckily it doesn't work in the same way:

$ lxterminal --command "bash /home/foo/scripts/"
HOME=/home/foo XDG_CONFIG_HOME=/home/foo/.config


It seems like .bashrc is not sourced in this way. I tried with .profile too, but with the same result. Is there another file sourced by lxterminal when called with the above command?

The reason why I need this command is because I want to launch these my own scripts through links/launchers I added to the start-menu and they have to be executed on a lxterminal window.

share|improve this question
up vote 4 down vote accepted

Try forcing bash to use interactive mode:

lxterminal --command "bash -i /home/foo/scripts/"

This happens because:

  • ~/.bashrc is read in interactive mode;

  • ~/.bash_profile, ~/.bash_login and ~/.profile are read in login mode.

See Invocation in man bash.

share|improve this answer
Thanks for the tip: it worked like a charm. And thanks for the man part too ;) Sometimes it's hard to find something when you don't know exactly what to search ... – Luca Borrione Feb 22 '12 at 13:31

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.