SlackwareThis Forum is for the discussion of Slackware Linux.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I'm not exactly a noob, and I've searched this, but am looking for something in particular.
To get my xterms, aterms, and the like to display the right prompt, ls colors, etc, I've added
This works fine as long as I stay in X. However, logging in to normal text console will display the fortune twice, as it's being read first from /etc/profile, then read again from .bashrc ...
Is there a simple way to have .bashrc source /etc/profile if I'm on a non-login shell, but not if I'm logging in from console?
PS -- It's just the idea of redundancy that I'm trying to get around. I realize I could simply put PS1, my aliases and ls -color and so forth, but I'm trying to find a way to read the system-wide /etc/profile file only once, in all cases.
I had 'source /etc/profile' in .bash_profile, not .bashrc
.bash_profile is read only by a login shell...
From the O'Reilly Learning the Bash Shell book:
If you start up a new shell by typing bash on the command line, it will attempt to read commands from the file .bashrc. This scheme allows you the flexibility to separate startup commands needed at login time from those you might need when you run a subshell. If you need to have the same commands run regardless of whether it is a login shell or subshell, you can just use the source fommand from within .bash_profile to execute .bashrc.
I understand the scheme now. .bashrc is read for subshells, .bash_profile for login shells. Login shells begin by reading /etc/profile, and continue on to read .bash_profile... That's where my problem was. All I need is the .bashrc to source /etc/profile, and subshells will behave the same.