On Wed, Jul 10, 2019 at 09:15:14AM -0400, Chet Ramey wrote: > On 7/10/19 4:01 AM, westlake wrote: > > If a normal user types "su -l<enter>" and issues this "ls" statement, > This account has the `extglob' shell option enabled.
"su -l" gives you a login shell, so this instance of bash is reading /etc/profile and ~root/.profile (or other login-shell-only dot files). > > If "su<enter>" (without the -l), is given instead, then "!" is taken to be > This account does not. "su" without "-" or "-l" gives a non-login shell, so this instance of bash is only reading ~root/.bashrc (and possibly some vendor-specific files in /etc, possibly /etc/bash.bashrc or /etc/bashrc, depending on the vendor's compile-time options). Understanding the difference between a login shell and a non-login shell is the primary issue here. If you actually want to track down where the extglob setting is coming from (or not coming from), I'd start with ~root/.profile and ~root/.bashrc as the most likely places to look. Enabling extglob *should* be done in .bashrc (if it's going to be done at all), and .bashrc *should* be sourced from .profile or .bash_profile in order to ensure that login shells and non-login shells both have the same basic options enabled. My first guess is your .profile isn't sourcing your .bashrc the way it should. But there are myriad other ways this could have been misconfigured, and the only way to be sure will be to dig through all of the dot files.