LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   what is the source file for sh (https://www.linuxquestions.org/questions/linux-newbie-8/what-is-the-source-file-for-sh-792734/)

nasridine 03-02-2010 06:52 PM

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?

chrism01 03-02-2010 07:36 PM

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.

nasridine 03-03-2010 09:10 AM

Quote:

Originally Posted by chrism01 (Post 3883298)
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?

catkin 03-03-2010 09:44 AM

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.

nasridine 03-05-2010 04:52 PM

Quote:

Originally Posted by catkin (Post 3883991)
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?

catkin 03-05-2010 09:54 PM

Quote:

Originally Posted by nasridine (Post 3887553)
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.


All times are GMT -5. The time now is 01:46 PM.