LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 03-02-2010, 06:52 PM   #1
nasridine
Member
 
Registered: Jan 2010
Posts: 52

Rep: Reputation: 15
what is the source file for sh


This machine has sh as the shell default. Where is the source file for this shell? I only have .bashrc under my directory. How do I have it sourced automatically at login in?
 
Old 03-02-2010, 07:36 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,357

Rep: Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367
sh is normally /bin/sh
Try

which sh

to check

The login sequence starts with /etc/profile, then calls your local .bashrc and/or .bash_profile. You default shell is set in your entry in /etc/passwd; it's the last field.
 
Old 03-03-2010, 09:10 AM   #3
nasridine
Member
 
Registered: Jan 2010
Posts: 52

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by chrism01 View Post
sh is normally /bin/sh
Try

which sh

to check

The login sequence starts with /etc/profile, then calls your local .bashrc and/or .bash_profile. You default shell is set in your entry in /etc/passwd; it's the last field.
I don't have access to /etc/profile, so I added some alias in .bashrc. It seems to me this file is not sourced automatically, because only if I source .bashrc manually, the alias takes effect.

I did see this block in /etc/profile:

test -r /etc/bash.bashrc && . /etc/bash.bashrc
if test "$is" = "bash" -a -z "$_HOMEBASHRC" ; then
# loop detection
readonly _HOMEBASHRC=true
test -r $HOME/.bashrc && . $HOME/.bashrc
fi

However, my shell is not bash, how to ask sh to source .bashrc by itself?
 
Old 03-03-2010, 09:44 AM   #4
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
If /bin/sh is a link to /bin/bash (as is common) then bash, invoked as sh, will not source ~/.bashrc but ~/.profile as explained here (scroll down to the "Invoked with name sh" section).

The output of /bin/ls -l /bin/sh would show whether /bin/sh is a link to /bin/bash.
 
Old 03-05-2010, 04:52 PM   #5
nasridine
Member
 
Registered: Jan 2010
Posts: 52

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by catkin View Post
If /bin/sh is a link to /bin/bash (as is common) then bash, invoked as sh, will not source ~/.bashrc but ~/.profile as explained here (scroll down to the "Invoked with name sh" section).

The output of /bin/ls -l /bin/sh would show whether /bin/sh is a link to /bin/bash.
Yes, you are right, my sh is linked to bash. So .bash_profile is supposed to be sourced automatically right (I don't have a .profile under my dir).

I have this in my ~/.bash_profile to show dirs in color
export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad

However everytime I log in, it never works until I source the .bash_profile manually.

Should I generate a .profile and put these in it, so if will get sourced by itself?
 
Old 03-05-2010, 09:54 PM   #6
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 nasridine View Post
Yes, you are right, my sh is linked to bash. So .bash_profile is supposed to be sourced automatically right
Not right for reasons explained in my post above with full detail on the page linked there.
 
  


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
[SOLVED] make use of gcc source code to parse c++ source file famsinyi Programming 14 10-19-2009 06:47 PM
source code file 'Not a local file' error with anjuta 2.4.2 PrathuD Linux - Newbie 2 10-24-2008 10:36 AM
I have a make file and source file. I want to use Kdevelop JonBrant Programming 4 10-15-2006 10:07 AM
making a playlist file from a html source file linuxhippy Slackware 2 06-30-2006 07:14 AM
How to build a rpm file from the source file? Flamenco Mandriva 5 12-22-2004 03:40 AM


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