I need a script which is run on startup of
echo 'hello world'
/bin/sh is a symlink to
/bin/bash, which has quite a few rules about startup scripts, with special cases when called
If bash is invoked with the name sh, it tries to mimic the startup behavior of historical versions of sh as closely as possible, ...
If you start it from the console, without any command, i.e. as an interactive, non-login shell, you should use the
ENV variable :
export ENV=~/.profile sh
When invoked as an interactive [non login] shell with the name sh, bash looks for the variable ENV, expands its value if it is defined, and uses the expanded value as the name of a file to read and execute.
Alternatively you can use the
--login option to make it behave like a login shell, and read the
When invoked as an interactive login shell [with the name sh], or a non-interactive shell with the --login option, it first attempts to read and execute commands from /etc/profile and ~/.profile, in that order