Date: Fri, 8 Dec 2023 17:16:26 +0100 From: Polytropon <freebsd@edvax.de> To: LuMiWa <lumiwa@dismail.de> Cc: FreeBSD Questions <freebsd-questions@freebsd.org> Subject: Re: sh shell Message-ID: <20231208171626.54bd2581.freebsd@edvax.de> In-Reply-To: <20231208052849.00987310@dismail.de> References: <20231208052849.00987310@dismail.de>
next in thread | previous in thread | raw e-mail | index | archive | help
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, ...
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20231208171626.54bd2581.freebsd>