LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
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,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
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



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

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

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