3

I am currently trying to setup some bash definitions (functions, variables) that need to be available for all the users that access a workstation. I have created shell scripts with .sh extension in /etc/profile.d/ directory that have all the necessary. In theory, these should be run once a user logs into the system.

Unfortunately, none of these are available to the users when they use the workstation. The current work-around is to manually source them.

What puzzles me is that these scripts are run when users login remotely via ssh. :|

What am I missing here?

1 Answers1

2

/etc/profile and the files in /etc/profile.d are read by login shells. That's fine for doing things like setting environment variables, which are inherited by child processes: this way they're set in all the programs in the session. It's no good for shell settings such as function definitions, since they're only available in that shell instance. For shell settings, you need to use a shell configuration file instead of a session configuration file. For bash, that's ~/.bashrc, and (on systems where it's enabled) /etc/bash.bashrc.

For more information, see Is there a ".bashrc" equivalent file read by all shells? and Difference between Login Shell and Non-Login Shell?