LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-27-2013, 05:22 PM   #1
lxas
LQ Newbie
 
Registered: Feb 2013
Posts: 3

Rep: Reputation: Disabled
Why any command in .bashrc is being executed twice


This is my .bashrc file. Now as in the attached screenshot, it seems that the echo "Hello World" is being executed twice.
Could anybody please help me understand this? My emulator is LXTerminal.

# Add nano as default editor
export EDITOR=nano
alias ls='ls --color=auto'
#If not running interactively, don't do anything
[[ $- != *i* ]] && return

PS1='[\u@\h: \W]\$ '

echo "Hello World"
 
Old 02-27-2013, 07:24 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
Can you check your .bash_profile; its normally called from there.
 
Old 02-27-2013, 09:01 PM   #3
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Can you once share, what you see on terminal after you login i.e. enter in your session?

Also the same could be there in .profile file as well. Since shell executes .bashrc as well .profile or .login etc.

Code:
~$ grep 'Hello' .profile .login
 
Old 02-28-2013, 07:29 AM   #4
lxas
LQ Newbie
 
Registered: Feb 2013
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thank you very much for your reply. I see this when open LXTerminal:

Hello World
Hello World
[sakibccr@cdc: ~]$


And the grep output is this:

grep: .profile: No such file or directory
grep: .login: No such file or directory

I checked in the file manager, there is no .profile or .login file. My distro is Archbang with Openbox WM and SpaxeFM file manager.
 
Old 02-28-2013, 08:15 AM   #5
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,163
Blog Entries: 10

Rep: Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979
Quote:
Originally Posted by lxas View Post
This is my .bashrc file. ...My emulator is LXTerminal.

# Add nano as default editor
export EDITOR=nano
alias ls='ls --color=auto'
#If not running interactively, don't do anything
[[ $- != *i* ]] && return

PS1='[\u@\h: \W]\$ '

echo "Hello World"
First off, Much Respect for calling it by it's correct definition "emulator".
2nd: Is that the entire .bashrc file contents? It seems a bit "short".
 
Old 02-28-2013, 11:59 AM   #6
lxas
LQ Newbie
 
Registered: Feb 2013
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thank you very much @Habitual. I was using Ubuntu as my primary OS for quite some time, but could not gather much knowledge though.

Yes it is the entire .bashrc file.
 
Old 02-28-2013, 12:18 PM   #7
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,163
Blog Entries: 10

Rep: Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979
Quote:
Originally Posted by lxas View Post
Thank you very much @Habitual. I was using Ubuntu as my primary OS for quite some time, but could not gather much knowledge though.

Yes it is the entire .bashrc file.
Well, we all recover from some things better than others.
You are in the right place to learn stuff.

Welcome to LQ.

I can't answer your question directly as to what may be the issue, I just ask the obvious more often than not.

Have you tried removing the 'echo "Hello World"' from .bashrc to see if the issue persists?
There is another option to create a new .bashrc from a skeleton file, but I am not clear on
those instructions.

Please be patient, someone much smarter than I will be along to help.

Have a Great Day!
 
Old 02-28-2013, 08:43 PM   #8
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Quote:
Originally Posted by lxas View Post
grep: .profile: No such file or directory
grep: .login: No such file or directory
In that case, if there's no .profile or .login, search .bashrc and all other executables inside home directory as:
Code:
~$ grep 'Hello' .bashrc
~$ grep 'Hello' ~/*
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ShellScript executed from command prmpt but not executed from crontab or at command BMMadhav Linux - Newbie 1 11-16-2012 08:20 PM
it looks like .bashrc isn't executed lord_didger Linux - Software 4 01-29-2008 09:02 AM
When .bashrc is executed? SeRGeiSarov Programming 4 07-31-2007 01:40 PM
.bashrc and .bash_profile not executed enlight1 Fedora 5 06-27-2006 09:24 PM
.bashrc not being executed, why? realos Linux - Newbie 1 12-20-2003 08:46 PM


All times are GMT -5. The time now is 10:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration