Skip to content

Instantly share code, notes, and snippets.

@rollin96
Created May 11, 2018 02:18
Show Gist options
  • Save rollin96/d1e598523678ddaf2a3ddd802179080e to your computer and use it in GitHub Desktop.
Save rollin96/d1e598523678ddaf2a3ddd802179080e to your computer and use it in GitHub Desktop.
from https://unix.stackexchange.com/a/29811
Using su without -l or - starts bash as an interactive, but non-login shell, which doesn't read from either of the files you specified. Use the -l or - option or put the relevant config into /root/.bashrc.
Quick summary of config files:
* Login shell (-l/--login) reads /etc/profile first, and then the first it finds of: ~/.bash_profile, ~/.bash_login, and ~/.profile.
* Interactive but non-login shell (-i) reads /etc/bash.bashrc and ~/.bashrc, in that order (unless the --rcfile option is used and tells it to look elsewhere).
* Non-interactive shells, e.g. started from within another program without using the -l or -i flags, reads the file specified in the BASH_ENV environment variable.
* When run as sh as a login shell, it will read /etc/profile and ~/.profile, in that order.
* When run as sh as an interactive non-login, it reads the file specified in ENV.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment