LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-08-2015, 05:46 PM   #1
usao
Member
 
Registered: Dec 2011
Location: Chandler, AZ
Posts: 286

Rep: Reputation: Disabled
Bash login shell not running .bashrc


When I login (using ssh) to CentOS 6.6 with an account configured to use /bin/bash, the shell does not read the .bashrc file located in $HOME.
I set the file permissions to 744, but it's still not reading the file and I have to manually issue ". $HOME/.bashrc" to get the contents loaded.

Any ideas on what I should be looking for to fix this problem?
 
Old 09-08-2015, 06:42 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599
Quote:
Originally Posted by usao View Post
When I login (using ssh) to CentOS 6.6 with an account configured to use /bin/bash, the shell does not read the .bashrc file located in $HOME.
With an interactive login shell it should be loading by default /etc/profile, then /etc/inputrc, then any /etc/profile.d/*.sh, then ~/.bash_profile and then ~/.bashrc. So what have you changed globally or locally since you've created the account?


Quote:
Originally Posted by usao View Post
I set the file permissions to 744, but it's still not reading the file and I have to manually issue ". $HOME/.bashrc" to get the contents loaded.
It's sourced not executed, it should have max octal 0640.
 
Old 09-08-2015, 06:58 PM   #3
usao
Member
 
Registered: Dec 2011
Location: Chandler, AZ
Posts: 286

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by unSpawn View Post
With an interactive login shell it should be loading by default /etc/profile, then /etc/inputrc, then any /etc/profile.d/*.sh, then ~/.bash_profile and then ~/.bashrc. So what have you changed globally or locally since you've created the account?



It's sourced not executed, it should have max octal 0640.
AFAIK only the $HOME/.bashrc file has been changed. I created the account today. I can change perms to 640 and see if that makes any difference.
ls: cannot access /export/home/user/.bash_profile: No such file or directory
-rw-r--r--. 1 root root 942 Jan 12 2010 /etc/inputrc
-rw-r--r--. 1 root root 1796 Oct 2 2013 /etc/profile
-rw-r--r--. 1 root root 1143 Jul 16 2014 /etc/profile.d/colorls.sh
-rw-r--r--. 1 root root 192 Sep 9 2014 /etc/profile.d/glib2.sh
-rw-r--r--. 1 root root 2706 Nov 4 2014 /etc/profile.d/lang.sh
-rw-r--r--. 1 root root 121 Jun 4 2014 /etc/profile.d/less.sh
-rwxr-xr-x. 1 root root 153 Aug 22 2010 /etc/profile.d/mc.sh
-rw-r--r--. 1 root root 269 Apr 5 2012 /etc/profile.d/vim.sh
-rw-r--r--. 1 root root 169 May 20 2009 /etc/profile.d/which2.sh
-rwxr--r--. 1 user user 1228 Sep 8 14:44 /export/home/user/.bashrc
 
Old 09-08-2015, 07:22 PM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599
Quote:
Originally Posted by usao View Post
Code:
ls: cannot access /export/home/user/.bash_profile: No such file or directory
So /export/home/user/ doesn't have any .bash_profile. NP, BASH should be able to function without it except:
Code:
~]$ head -4 .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
 
Old 09-09-2015, 09:39 AM   #5
usao
Member
 
Registered: Dec 2011
Location: Chandler, AZ
Posts: 286

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by unSpawn View Post
So /export/home/user/ doesn't have any .bash_profile. NP, BASH should be able to function without it except:
Code:
~]$ head -4 .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
Ah, wasn't aware there was a requirement for .bash_profile. I though BASH automatically sourced the $HOME/.bashrc.
So, in reality, BASH sources .bash_profile, so I could just put my stuff in there instead of .bashrc.
 
Old 09-09-2015, 10:46 AM   #6
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 4,748

Rep: Reputation: 2203Reputation: 2203Reputation: 2203Reputation: 2203Reputation: 2203Reputation: 2203Reputation: 2203Reputation: 2203Reputation: 2203Reputation: 2203Reputation: 2203
A login shell (interactive or non-interactive) sources /etc/profile and then looks for ~/.bash_profile, ~/.bash_login, and ~/.profile in order, and sources the first one it finds.

An interactive non-login shell sources ~/.bashrc.

The "INVOCATION" section of the bash manpage spells this out in great detail.

It is very common for ~/.bash_profile to have a line that explicitly sources ~/.bashrc, but that is the only way that your .bashrc gets routinely sourced by a login shell.
 
  


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
~/.bashrc, /etc/bash.bashrc files not read? Tachtory Slackware 3 01-04-2014 01:25 AM
[SOLVED] Need help for bash. Difference between login and non login shell aashayshah Linux From Scratch 1 03-13-2013 09:15 PM
"exit" in bash .bashrc procedure/shell function exits xterm anonguy9 Linux - Newbie 11 07-13-2011 04:54 PM
Bash script not running on shell login. uncle-c Linux - Newbie 8 02-21-2009 10:41 AM
SLSE9 login issue with bash.bashrc iverger SUSE / openSUSE 0 11-18-2004 10:43 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:50 PM.

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
Open Source Consulting | Domain Registration