LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 08-09-2004, 01:13 AM   #1
kaon
Member
 
Registered: Dec 2003
Location: Hong Kong SAR
Distribution: Slackware 9.1, 10.x, slackware-current
Posts: 186

Rep: Reputation: 30
source /etc/profile


I came across many posts, but none gives me any idea or solution. Just to ask here again.

What changes should I make such that /etc/profile will be run automatically at each startup?

Thanks.
 
Old 08-09-2004, 01:44 AM   #2
slyman
Member
 
Registered: Jun 2004
Location: Sydney, Australia
Distribution: FC3, Linux From Scratch, Knoppix
Posts: 99

Rep: Reputation: 15
Do you mean each time you open a terminal?

/etc/profile is run everytime you start up, just not everytime you open a terminal e.g. xterm. This is controlled by .bashrc and .bash_profile.

To make sure everything in /etc/profile and in ~/.profile is picked up every time I open a terminal, I have the following files and their contents in my home directory:

.bashrc:
Code:
source /etc/profile
source ~/.profile
.bash_profile:
Code:
source .bashrc
Just in case you did not know, /etc/profile is global and .profile is for each user e.g. root will use .profile to add /sbin and /usr/sbin to $PATH.

Last edited by slyman; 08-09-2004 at 01:52 AM.
 
Old 08-09-2004, 02:18 AM   #3
kaon
Member
 
Registered: Dec 2003
Location: Hong Kong SAR
Distribution: Slackware 9.1, 10.x, slackware-current
Posts: 186

Original Poster
Rep: Reputation: 30
Quote:
Originally posted by slyman
Do you mean each time you open a terminal?

/etc/profile is run everytime you start up, just not everytime you open a terminal e.g. xterm. This is controlled by .bashrc and .bash_profile.
/etc/profile won't be picked up at all, say after I login, the tty displays "bash-2.05b#" instead of path name and no color formatting when I typed in "ls". I have to type in "source /etc/profile" manually each time.

Quote:
Originally posted by slyman
To make sure everything in /etc/profile and in ~/.profile is picked up every time I open a terminal, I have the following files and their contents in my home directory:

.bashrc:
Code:
source /etc/profile
source ~/.profile
.bash_profile:
Code:
source .bashrc
Just in case you did not know, /etc/profile is global and .profile is for each user e.g. root will use .profile to add /sbin and /usr/sbin to $PATH.
Just a few more questions.
1) Why do we need both .bashrc nad .bash_profile?
2) Where should these 2 files be put?
3) Is there any precedence over each other?

Thanks.

Last edited by kaon; 08-09-2004 at 02:19 AM.
 
Old 08-09-2004, 03:02 AM   #4
slyman
Member
 
Registered: Jun 2004
Location: Sydney, Australia
Distribution: FC3, Linux From Scratch, Knoppix
Posts: 99

Rep: Reputation: 15
Quote:
Originally posted by kaon
[B]/etc/profile won't be picked up at all, say after I login, the tty displays "bash-2.05b#" instead of path name and no color formatting when I typed in "ls". I have to type in "source /etc/profile" manually each time.
You mean if you boot up and log in through a text console or do you mean when you open up xterm (or similar) in X?


Quote:
Just a few more questions.
1) Why do we need both .bashrc nad .bash_profile?
Google.

Quote:
2) Where should these 2 files be put?
in a users home directory.

Quote:
3) Is there any precedence over each other?
Google.
 
Old 08-09-2004, 03:18 AM   #5
jomen
Senior Member
 
Registered: May 2004
Location: Leipzig/Germany
Distribution: Arch
Posts: 1,684

Rep: Reputation: 54
man bash is probably the easier and faster way - it is rather long tough - but it explains it all - the precedence of one over another, the names and which file is read under which circumstances...

If you read that - and know, how it is supposed to be working, then use google to find the solution to your problem or ask again here
 
Old 08-09-2004, 03:38 AM   #6
kaon
Member
 
Registered: Dec 2003
Location: Hong Kong SAR
Distribution: Slackware 9.1, 10.x, slackware-current
Posts: 186

Original Poster
Rep: Reputation: 30
Sorry guys that I should search things in google b4 asking.

Quote:

You mean if you boot up and log in through a text console or do you mean when you open up xterm (or similar) in X?
Both (text console and xterm in X) won't pick up /etc/profile unless I type in "source /etc/profile" manually.
 
Old 08-09-2004, 04:02 AM   #7
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,962
Blog Entries: 11

Rep: Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865
That's a quite amazing phenomenon ... it appears that your
bash thinks it's not a login-shell under any circumstances.

What distro are you using atm? Slack? If so, which version?
What does /etc/passwd look like, what happens if you try
to run login from that shell?


Cheers,
Tink
 
Old 08-09-2004, 08:27 AM   #8
320mb
Senior Member
 
Registered: Nov 2002
Location: pikes peak
Distribution: Slackware, LFS
Posts: 2,577

Rep: Reputation: 47
Quote:
Originally posted by kaon

Just a few more questions.
1) Why do we need both .bashrc nad .bash_profile?
2) Where should these 2 files be put?
3) Is there any precedence over each other?

Thanks.
Quote:
# System wide environment variables and startup programs should go into
# /etc/profile. Personal environment variables and startup programs
# should go into ~/.bash_profile. Personal aliases and functions should
# go into ~/.bashrc

Tinkster is right.........this is very odd behavior.............you should never have to source /etc/profile in the ~/.bashrc
I don't need to do this at all for Slackware or either of my two LFS systems..............
 
Old 08-09-2004, 08:58 AM   #9
bmac83
LQ Newbie
 
Registered: Aug 2004
Distribution: Slackware 10.0
Posts: 13

Rep: Reputation: 0
I haven't had that problem with the tty's, but I did have to do some tinkering to get a login shell with rxvt. I just added a line to my ~/.Xresources file:

Code:
rxvt*loginShell: True
You can do this on the command line with

Code:
rxvt +ls
I hope that will help, at least to diagnose the problem further. Bash newbie thought: could it be that the permissions for the /etc/profile aren't right? Mine has world read permissions, and root has read/write permissions.
 
Old 08-09-2004, 05:08 PM   #10
slyman
Member
 
Registered: Jun 2004
Location: Sydney, Australia
Distribution: FC3, Linux From Scratch, Knoppix
Posts: 99

Rep: Reputation: 15
Quote:
Originally posted by 320mb
you should never have to source /etc/profile in the ~/.bashrc
I don't need to do this at all for Slackware or either of my two LFS systems..............
Even for xterm?

Unless I source /etc/profile and ~/.profile in .bashrc, I have to start xterm as a login shell (xterm -ls).
 
Old 08-09-2004, 05:22 PM   #11
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,962
Blog Entries: 11

Rep: Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865
Quote:
from man bash
Code:
       When  bash is invoked as an interactive login shell, or as
       a non-interactive shell with the --login option, it  first
       reads and executes commands from the file /etc/profile, if
       that file exists.  After reading that file, it  looks  for
       ~/.bash_profile,  ~/.bash_login,  and  ~/.profile, in that
       order, and reads and executes commands from the first  one
       that  exists  and is readable.  The --noprofile option may
       be used when the shell is started to inhibit  this  behav-
       ior.
I have to get back at kaon's original suggestion:
Other than the #bash-2.05 prompt, what indication is there
that /etc/profile is not being picked up? If you do an env
in a shell (before sourcing profile) you should have a pretty
much empty path ... is that the case?


Cheers,
TInk
 
Old 08-09-2004, 09:10 PM   #12
kaon
Member
 
Registered: Dec 2003
Location: Hong Kong SAR
Distribution: Slackware 9.1, 10.x, slackware-current
Posts: 186

Original Poster
Rep: Reputation: 30
Sigh... I have no time to do "man bash"

Quote:
Originally posted by Tinkster
I have to get back at kaon's original suggestion:
Other than the #bash-2.05 prompt, what indication is there
that /etc/profile is not being picked up? If you do an env
in a shell (before sourcing profile) you should have a pretty
much empty path ... is that the case?


Cheers,
TInk
Since by default (I think, newbie in Slackware) , Slackware does not have color highlighting unless I key in "ls --color"or "ls --tty". Therefore, I came across some posts about system-wide color highlighting. They suggest putting an alias in /etc/profile (alias 'ls'='ls --tty', I may get it wrong, coz I am @ the office now with Windows ). I followed and reboot afterwards. After serveral time login as root (Soon will create an account myself ), neither text console nor xterm gives what I expected. So I have to type in "source /etc/profile" and finally it gives color highlighting and the prompt is no longer displayed as "bash-2.05b#" but the path name and username. (I remembered I did not face this problem using slack 9.1)

Quote:
]Originally posted by 320mb
# System wide environment variables and startup programs should go into
# /etc/profile. Personal environment variables and startup programs
# should go into ~/.bash_profile. Personal aliases and functions should
# go into ~/.bashrc
Start wondering I may misput the alias in /etc/profile, but I want it to be system-wide setting.
 
Old 08-09-2004, 09:45 PM   #13
Mephisto
Member
 
Registered: Oct 2002
Location: Washington D.C, USA
Distribution: Slack 12, Etch, Gutsy
Posts: 453

Rep: Reputation: 30
Quote:
Originally posted by kaon
Sigh... I have no time to do "man bash"
If you don't have time to read the documentation, then you are going to have issues with Slack. Not a judgement, just an observation. That said it sounds like you mucked up your "profile" script, If I were to hazard a guess it is no longer executing to completion because of whatever you changed. You might try executing it by hand and seeing what error messages come up.

To add your alias for all users create a sh script in the /etc/profile.d directory and make it executable. I ususally add a /etc/profile.d/local.sh for my custom aliases. When the /etc/profile script is not broken all executable scripts in the profile.d are executed for login shells.
 
Old 08-09-2004, 10:02 PM   #14
kaon
Member
 
Registered: Dec 2003
Location: Hong Kong SAR
Distribution: Slackware 9.1, 10.x, slackware-current
Posts: 186

Original Poster
Rep: Reputation: 30
I got no time just because I have to work with Windozes recently :P
I'll try to deal with the problem again tonight. And hopefully, it works again.

I will ask for help if I have any problem again. Thx u guys.
 
  


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
non roaming profile on a roaming profile system fieldyweb Linux - Newbie 1 10-03-2005 12:27 PM
gprof - annotate source, profile directed compiling iansworld Linux - Software 0 03-25-2005 12:33 PM
where is linux source build directory/kernel source tree? webazoid Linux - Software 2 07-01-2004 08:37 PM
source /etc/profile? why? what is it? piratebiter Linux - General 3 09-09-2003 11:36 AM
.profile not be source when using ksh93. NEED HELP!!!! michaeldm9 Linux - General 0 08-28-2003 08:29 AM


All times are GMT -5. The time now is 07:36 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration