4 ms·
as far as I can tell when I open new shells .profile isn't read True, iff you have a .bash_profile. Bash only reads the first of ~/.bash_profile, ~/.bash_login
by tremon 7y ago
as far as I can tell when I open new shells .profile isn't read
True, iff you have a .bash_profile. Bash only reads the first of ~/.bash_profile, ~/.bash_login, ~/.profile. It will ignore the rest of the list once it's found an existing file.
- ashtonbaker 7y agoThis explains so many of my problems. Thank you.
- deleted 7y ago[deleted]
- em500 7y agohttps://hackernoon.com/bash-profile-vs-bashrc-vs-bin-bash-vs-etc-bash-tutorial-help-example-not-found-command-linux-mac-1c7f98c11186 https://hackernoon.com/bash-profile-vs-bashrc-vs-bin-bash-vs... Note that in macOS every new Terminal (tab) opens a login shell, while most GUI Linux environments don't. (In Tmux/screen it depends on the configuration).
- jolmg 7y agoStill, they're not read with every new interactive shell. They're read only with login shells. From the manual: > 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, > When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc So, this is wrong: > bashrc refers to something that runs in each and every new shell Because .bashrc doesn't run when you execute a shell script, and doesn't run when you use `bash -c`. And this is wrong: > profile refers to something that runs only in interactive shells Because it does run in non-interactive shells when they're login shells, and because it implies that it runs in every interactive shell, which it doesn't. It only runs in login shells.
- lloeki 7y agoInsanely enough, this is set up wrong in Debian and derivatives, where bash_profile sources bashrc as a default from /etc/skel, leading to damning "not a tty" messages because at some point it calls some tty requiring command unconditionally.