One interesting thing I discovered was there are system-wide profile and bash profile scripts.
/etc/profile /etc/.bashrc
In case you need to set these for every account.
One interesting thing I discovered was there are system-wide profile and bash profile scripts.
/etc/profile /etc/.bashrc
In case you need to set these for every account.
> The primary thing to understand is that the rc files are for all shell invocations while the profiles are strictly for interactive shells. An interactive shell is where you (end user) types the command while an non-interactive shell is when shells are launched by other programs such as a script with #!/bin/bash as SHEBANG value
[1] https://www.golinuxcloud.com/bashrc-vs-bash-profile/
So, what are use cases in which a non-interactive shell is launched? One example is a cron jobt that runs every night. It's basically the "cron" process executing a command which could be a bash script. Another example would be startup scripts that launch background processes and services which you'd find in /etc/system.
There's a distinction between interactive v. non-interactive and login v non-login as well [2]
https://dev.to/bijaykumarpun/linux-shells-interactive-non-in...
Typical issue would be adding something to your PATH variable in .profile, having your script work just fine in a shell, but having it fail when you run it as a cron job because .profile never gets sourced by cron.
If there is some non-interactive use of bash, I just want a clean environment, and everything scp or ssh needs should be on the standard $PATH.
There's no point in putting anything in .profile either, because if I am running an interactive session, I will be using bash. I don't care about the config for dash or whatever.
And any scripts should completely specify their required functions, $PATH and whatever inside the script itself. Use 'source' to pull in common functions.
That's not necessary or desirable in a non-login context.