Linux sysadmin question (since it's no longer possible to find actual answers via search on the Internet):

How can I configure the PATH to *always* have a specific directory in it when a shell (Bash) is started, regardless of whether the shell is login/non-login, interactive/non-interactive, etc.?

The normal steps (adding a file in /etc/profile.d which adds to the path) work for login/interactive shells, but not for shells opened by sshd with a command to execute (no pty).

#Linux #SysAdmin #LinuxSysAdmin

@kevin I've run into same pain. my two shotgun solutions:

1. always cite absolute path to your desired exe. so much BS goes away. DONE

or

2. revise all those scattered env-setting config files so each one imports/sources a single specific common file (like in .sh format), under the hood, that ensures PATH has the path prefix in it, adding it if needed at beginning or end

I don't think I've ever had 1 or 2 not suffice

The problem with relying on PATH is that some code is also sensitive to its CWD/PWD at runtime. To extend the shotgun approach I sometimes force those env values too inside scripts, so they are less fragile