Re: sh shell
- Reply: LuMiWa : "Re: sh shell"
- In reply to: LuMiWa : "sh shell"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 08 Dec 2023 16:16:26 UTC
On Fri, 8 Dec 2023 05:28:49 -0500, LuMiWa wrote: > I have FreeBSD 14.0-RELEASE-p2. Root shell is sh and user ksh. > In the root directory is .shrc and .sh_history which settings using if I > log as root or su -. But if I use just su if as I read should use also > root settings but it doesn't. It use .cshrc. Is it correct or I have > somewhere wrong setting, please? The commands "su -" and "su -l" serve the same purpose: They call the specified user's (or root's) shell as a login shell, so that shell will read the appropriate startup files. In case of the C shell, those are ~/.cshrc and ~/.login. The opposite of "su -l" (full login) is "su -m", which will keep the caller's environment and only start the shell, but not as a login shell. The shell's behaviour can be different on how it is called: as a login shell, as an interactive shell, or as a script shell; similarly, the files read on shell startup can be different, and there is precedence with possibly existing files in /etc or /usr/local/etc for global (vs. user-local) shell settings. However, you wrote "Root shell is sh and user ksh. [...] But if I use just su [...] It use .cshrc." - no, sh will not use ~/.cshrc. The startup and configuration files are listed in "man sh" (and "man csh" lists other files). So for a full login including getting the desired user's shell settings, "su -" or "su -l" is desired; "su -" is the common way to achieve this to become root. -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...