Bug 20893
Summary: | BASH /etc/profile and ~/bash_profile Not Read | ||
---|---|---|---|
Product: | [Retired] Red Hat Linux | Reporter: | Need Real Name <redhat> |
Component: | bash | Assignee: | Bernhard Rosenkraenzer <bero> |
Status: | CLOSED NOTABUG | QA Contact: | |
Severity: | medium | Docs Contact: | |
Priority: | high | ||
Version: | 7.0 | CC: | bradd+redhat, redhat |
Target Milestone: | --- | ||
Target Release: | --- | ||
Hardware: | i386 | ||
OS: | Linux | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | Bug Fix | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2000-11-15 14:00:02 UTC | Type: | --- |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
Need Real Name
2000-11-15 04:08:12 UTC
This is actually the intended behavior. If both /etc/bashrc and /etc/profile exist, bashrc is executed by bash. /etc/profile can be used for non-bash shells. ~/.bashrc is executed in a shell that is not a login shell, such as xterms. ~/.bash_profile is executed in login shells, such as the shells on a real vc. See the man page for further information. I recently observed the same problems as this person... /etc/profile is not executed on login. The resolution to this doesn't handle this problem. However, I have investigated it further. It seems the problem only crops up if you use KDM as the graphical login. If you use the text login, there is no problem. I think this has to do with KDM only starting bash in non-interactive mode. I have basically the same problem. It may be a feature, but no one notified that it was changing. My scripts used to work just fine, I installed 7.0 and it took me until now to figure out exactly why my scripts werent being run. bero commented: "If both /etc/bashrc and /etc/profile exist, bashrc is executed by bash. /etc/profile can be used for non-bash shells." Not according to the bash(1) manpage. It says, "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." There is no mention of /etc/bashrc in the bash manpage at all. I'm still working to determine what really does happen; however, either your remark or the manpage is incorrect. After some testing, I've determined that bash does behave according to the manpage: For a login shell, bash sources /etc/profile, then ~/.bash_profile. For a non-login interactive shell, bash sources ~/.bashrc. For a non-login, non-interactive shell, bash sources the script found in $BASH_ENV. The only way that bash should read /etc/bashrc is if one of the other initialization scripts explicitly sources it. The default scripts (from /etc/skel) do that. However, if you remove those lines from your ~/.bashrc, bash won't see /etc/bashrc at all. One thing users should be aware of: bash will ordinarily only see /etc/profile and ~/.bash_profile once, when you first log in (on a console, through X, or with "su -"). After that, it will only read ~/.bashrc, and only for interactive shells (ie., not for scripts). If you have explicitly sourced /etc/bashrc, it will see that too, and if you have set $BASH_ENV (perhaps with BASH_ENV=~/.bashrc), it will also work for non-interactive shells. |