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 04-01-2010, 04:55 PM   #1
bluethundr
Member
 
Registered: Jun 2003
Location: Summit, NJ
Distribution: CentOS 5.4
Posts: 124

Rep: Reputation: 15
.bash_profile not loading


well I am not so much of a newb timewise but this is kind of a newby question...

whenever I reboot my fedora core 12 box I find that my .bash_profile does not load... I have to issue source ~/.bash_profile


how do I get this to load automatically each time?

thanks!
 
Old 04-01-2010, 05:11 PM   #2
itsbrad212
Member
 
Registered: Nov 2009
Location: Chicago
Distribution: Arch and OpenBSD
Posts: 104

Rep: Reputation: 19
Try adding
Code:
source ~/.bash_profile
to your ~/.bashrc file
 
Old 04-01-2010, 05:12 PM   #3
kakaka
Member
 
Registered: Sep 2003
Posts: 382

Rep: Reputation: 87
I'm trying to understand how the reboot is involved in this situation.

Are you saying that the first time you login after a reboot, you have to manually load your .bash_profile. Then when you login a second or third time, it will load OK on its own?

Or do you have the system configured to automatically log you in?
 
Old 04-01-2010, 07:15 PM   #4
gumaheru
LQ Newbie
 
Registered: Nov 2009
Posts: 20

Rep: Reputation: 0
The .bash_profile is sourced in at login. The .bashrc is source when opening a terminal after a login. You can source the .bashrc from the .bash_profile.

You say that your .bash_profile doesn't get source during login. Can you verify the permissions and ownership? Can you post your .bash_profile just in case there is something funky in it?
 
Old 04-02-2010, 01:30 AM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Quote:
Originally Posted by bluethundr View Post
whenever I reboot my fedora core 12 box I find that my .bash_profile does not load... I have to issue source ~/.bash_profile
What are the symptoms that make you think that?
 
Old 04-02-2010, 01:47 AM   #6
itsbrad212
Member
 
Registered: Nov 2009
Location: Chicago
Distribution: Arch and OpenBSD
Posts: 104

Rep: Reputation: 19
Quote:
Originally Posted by gumaheru View Post
The .bash_profile is sourced in at login. The .bashrc is source when opening a terminal after a login. You can source the .bashrc from the .bash_profile.

You say that your .bash_profile doesn't get source during login. Can you verify the permissions and ownership? Can you post your .bash_profile just in case there is something funky in it?
.bashrc isn't really loaded when you open a terminal. It is loaded when bash is loaded. You don't need to physically open xterm or something along those lines to use it, but I know what you meant
 
Old 04-02-2010, 10:49 AM   #7
bluethundr
Member
 
Registered: Jun 2003
Location: Summit, NJ
Distribution: CentOS 5.4
Posts: 124

Original Poster
Rep: Reputation: 15
Talking .bash_profile help

Hey guys,

Thanks for your help... Well what I really mean is that every time I load my bash environment (reboot or open a terminal) I want to set certain variables so that they turn up the same every time....

Here is my .bash_profile that I would _hope_ loads each time I start yet it does not...


Code:
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin:/usr/local/bin

export PATH
export HOMEIP=XX.XXX.XX.XXX
export ADMIN='bluethundr@XX.XXX.XX.XXX'
export PATH=$PATH:/home/bluethundr/bin/
export PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/NX/bin
export JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre/lib

ENV=~/.env
export ENV
. $ENV

export $EDITOR
As you can see, it calls an environment file where I set a few convenient variables. This is my .env file....

Code:
alias v=vim
alias a='ssh $ADMIN'
alias b='ssh $HOMEIP'
alias cfe='cd /home/bluethundr/cf/cci/trunk/etc/cfengine/masterfiles/inputs'
alias cfetc='cd /home/bluethundr/cf/cci/trunk/etc' 
alias more='less'

#-------------------------------------------------------------
# spelling typos - highly personnal and keyboard-dependent :-)
#-------------------------------------------------------------

alias xs='cd'
alias vf='cd'
alias moer='more'
alias moew='more'
alias kk='ll'
And finally this is my .bashrc

Code:
# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

# User specific aliases and functions
What I _tried_ to do was load my .bash_profile with the line 'source .bash_profile from this file.

If I do this, I notice that my machine of late SPECTACULARLY fails to log in to it's environment. It can sit there for several minutes until I switch out of the graphical environment to a shell and log in that way. My system is connected to active directory through an LDAP server.

If I remove the line 'source .bash_profile' from my .bashrc file this does not seem to happen.

And I've noticed, since I've connected this machine to LDAP I get this cryptic series of messages every time I source .bash_profile from the command line...

Code:
[bluethundr@harmony ~]$ source ~/.bash_profile
declare -x ADMIN="bluethundr@XX.XX.XX.XX"
declare -x COLORTERM="gnome-terminal"
declare -x CVS_RSH="ssh"
declare -x DBUS_SESSION_BUS_ADDRESS="unix:abstract=/tmp/dbus-TaxD2rzcVn,guid=fca71e1cb683481eafe7b7c14bb5ffb1"
declare -x DESKTOP_SESSION="gnome"
declare -x DISPLAY=":0.0"
declare -x ENV="/home/bluethundr/.env"
declare -x GDMSESSION="gnome"
declare -x GDM_KEYBOARD_LAYOUT="us"
declare -x GDM_LANG="en_US.UTF-8"
declare -x GNOME_DESKTOP_SESSION_ID="this-is-deprecated"
declare -x GNOME_KEYRING_PID="1453"
declare -x GNOME_KEYRING_SOCKET="/tmp/keyring-THcv5W/socket"
declare -x GTK_RC_FILES="/etc/gtk/gtkrc:/home/bluethundr/.gtkrc-1.2-gnome2"
declare -x G_BROKEN_FILENAMES="1"
declare -x HISTCONTROL="ignoreboth"
declare -x HISTSIZE="1000"
declare -x HOME="/home/bluethundr"
declare -x HOMEIP="XX.XXX.XX.XXX"
declare -x HOSTNAME="harmony.hq.communityconnect.com"
declare -x IMSETTINGS_INTEGRATE_DESKTOP="yes"
declare -x IMSETTINGS_MODULE="none"
declare -x JAVA_HOME="/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre/lib"
declare -x LANG="en_US.UTF-8"
declare -x LESSOPEN="|/usr/bin/lesspipe.sh %s"
declare -x LOGNAME="bluethundr"
declare -x LS_COLORS="rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.tbz=01;31:*.tbz2=01;31:*.bz=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.axa=01;36:*.oga=01;36:*.spx=01;36:*.xspf=01;36:"
declare -x MAIL="/var/spool/mail/bluethundr"
declare -x NXDIR="/usr/NX"
declare -x OLDPWD
declare -x ORBIT_SOCKETDIR="/tmp/orbit-bluethundr"
declare -x PATH="/usr/kerberos/sbin:/usr/kerberos/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/NX/bin"
declare -x PWD="/home/bluethundr"
declare -x QTDIR="/usr/lib/qt-3.3"
declare -x QTINC="/usr/lib/qt-3.3/include"
declare -x QTLIB="/usr/lib/qt-3.3/lib"
declare -x QT_IM_MODULE="xim"
declare -x SESSION_MANAGER="local/unix:@/tmp/.ICE-unix/1460,unix/unix:/tmp/.ICE-unix/1460"
declare -x SHELL="/bin/bash"
declare -x SHLVL="2"
declare -x SSH_ASKPASS="/usr/libexec/openssh/gnome-ssh-askpass"
declare -x SSH_AUTH_SOCK="/tmp/keyring-THcv5W/socket.ssh"
declare -x TERM="xterm"
declare -x USER="bluethundr"
declare -x USERNAME="bluethundr"
declare -x WINDOWID="20971523"
declare -x XAUTHORITY="/var/run/gdm/auth-for-bluethundr-sAesn4/database"
declare -x XDG_SESSION_COOKIE="6d5a2ad7efa8e85fe13e8fa74bacff64-1270218672.876540-887625303"
declare -x XMODIFIERS="@im=none"
Any clues into this deepening mystery would be appreciated.

Thanks for playing! :-)
 
Old 04-02-2010, 11:24 AM   #8
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Quote:
Originally Posted by bluethundr View Post
Hey guys,

Thanks for your help... Well what I really mean is that every time I load my bash environment (reboot or open a terminal) I want to set certain variables so that they turn up the same every time....
Rebooting does not configure your bash environment. Logging in does and opening a graphical terminal emulator does. But the startup files that bash uses to configure a login shell are different from the ones it uses to configure a non-login interactive shell. Details here. That's not as daft as it sounds because non-login interactive shells are descendants of a login shell so they inherit the environment variables set during login shell initialisation.

Aliases set in the login shell startup files are only inherited if they are exported; an alternative solution is to set them in ~/.bashrc and source ~/.bashrc from one of the login shell startup files.
 
Old 04-02-2010, 12:35 PM   #9
gumaheru
LQ Newbie
 
Registered: Nov 2009
Posts: 20

Rep: Reputation: 0
I should have asked this at first. Is your default environmental shell even bash? If your default shell isn't bash then it won't even source these files after login.
 
Old 04-03-2010, 01:50 AM   #10
forusword
Member
 
Registered: Apr 2010
Location: USA
Distribution: OpenSUSE
Posts: 70

Rep: Reputation: 15
Did you look at your ~.bashrc file in your text editor? If you have check to see that it isn't just being remembered in the shell; which is a case point where you might consider, "WTF?". You variables should load according to what I've read above. I don't see too many cryptic variables there, only what your desktop has set, what you have set (which is as close to cryptic as I can differentiate). I had similar issues with my ~.bashrc profile not loading in the past; it was always sudo related and you may have noticed that I posted elsewhere about "how can I remove sudo (even though I know it is generally ill advised and a lot of people say just disable it)". Your problem could also lie here:

# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

# User specific aliases and functions

Note the whitespace in the line before fi. I was never too good with these lines though.
 
Old 04-03-2010, 01:52 AM   #11
forusword
Member
 
Registered: Apr 2010
Location: USA
Distribution: OpenSUSE
Posts: 70

Rep: Reputation: 15
oh and ditto the "is your default shell even bash posted above"
 
Old 04-03-2010, 05:05 AM   #12
kakaka
Member
 
Registered: Sep 2003
Posts: 382

Rep: Reputation: 87
I'm not quite sure what the issue was meant to be about this line:

Code:
. /etc/bashrc
so I'm not sure is this will help, but a single dot is a synonym for the source command built into bash. Just as you would have a space between the source command and the name of the file you were sourcing, so too there is a space after the dot.

Also, bash is said to look at it's existing environment when it starts and mark all the variables for export. "declare -x" would do exactly that, so that seems perfectly reasonable.

bluethundr, when you say that
Quote:
my machine of late SPECTACULARLY fails to log in to it's environment
what did you mean? What you went on to say sounded as though you weren't able to login via the graphic login screen.

I'm probably missing something, because at first blush it appears that you have a .bash_profile which sources your .bashrc. Then you appear to be saying that you added a line such as:

Code:
source .bash_profile
into your .bashrc - but I must be misinterpreting because that would seemingly create an infinite loop. A sources B which sources A which sources B and on and on...

So as others have asked, what originally made you think that your .bash_profile wasn't getting "sourced" when you login?
 
Old 04-03-2010, 05:15 AM   #13
forusword
Member
 
Registered: Apr 2010
Location: USA
Distribution: OpenSUSE
Posts: 70

Rep: Reputation: 15
i've noticed from my use of Linux sporadically over the last like, 2 or 3 years that whitespace isn't very welcome when using the BASH shell.

Quote:
Originally Posted by kakaka
A sources B which sources A which sources B and on and on...

So as others have asked, what originally made you think that your .bash_profile wasn't getting "sourced" when you login?
in answer:

Quote:
Originally Posted by bluethundr
Whenever I reboot my fedora core 12 box I find that my .bash_profile does not load... I have to issue source ~/.bash_profile
To me this effectively means that the bash file isn't sourced. It has to be sourced.
 
Old 04-03-2010, 05:17 AM   #14
forusword
Member
 
Registered: Apr 2010
Location: USA
Distribution: OpenSUSE
Posts: 70

Rep: Reputation: 15
I'm actually finding confusion with the use of bash_profile and ~./bashrc though because I don't recall editing two files in order to set environment variables and aliases. I only remember appending the ~./bashrc file; which I haven't done in some time either because I abandoned Linux for a while after Ubuntu went all crazy and turned gray screens all the time.
 
Old 04-03-2010, 05:19 AM   #15
forusword
Member
 
Registered: Apr 2010
Location: USA
Distribution: OpenSUSE
Posts: 70

Rep: Reputation: 15
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

could it be the lack of a line break in the first line here and the use of whitespace in the second line?
 
  


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
.bash_profile dimi Linux - General 1 08-23-2005 09:00 PM
.bash_profile sikandar Linux - Software 9 08-31-2003 11:01 AM
Finding Module Dependencies...(Still loading...still loading..still loading..HANG!!!) Aeudian Linux - General 3 08-11-2003 04:31 PM
Finding Module Dependencies.....(still loading....Still loading....still loading) Aeudian Linux - Newbie 1 07-28-2003 03:27 PM
.bash_profile Wasim Haider Linux - General 2 09-16-2002 08:12 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:18 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