Post #1317545
2026-04-05 15:54 UTC
@kevin This is for Bash specifically. Each shell works a bit differently.
For login shells (interactive or not), it runs `/etc/profile`, then `~/.bash_profile`, `~/.bash_login`, and `~/.profile`.
For interactive non-login shells, it runs `~/.bashrc`.
For non-interactive non-login shells, you have to set `BASH_ENV` to a script to run before you run Bash. You need to give the full path of the script, I think.
If you are running a script or command over sshd (rather than logging in and interacting with commands as usual), it'll run `~/.bashrc`.
Here's the doc page: https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html
Replies (1)
-
@kevin@mastodon.km6g.us 2026-04-05 15:56
@bryanredeagle Sadly the default ~/.bashrc (at least on Debian) exits immediately if the shell is non-interactive, so that doesn't help much and of course it isn't global. Thanks though 🙂