By default `machinectl shell` runs the user's shell with the "login" flag, exactly as during console or SSH logins. For Bash, that means it will look for ~/.bash_profile or ~/.profile *instead of* ~/.bashrc.
Usually people have a ~/.bash_profile that sets up "once per session" things if any, then manually sources ~/.bashrc (with the '.' or 'source' command) as Bash never does do so automatically.
The same applies to global configs; Bash in login mode will read /etc/profile, but not /etc/bash.bashrc unless the latter is explicitly sourced (e.g. Arch's /etc/profile has an "if [ "$BASH" ]; then . /etc/bash.bashrc; fi").
On Thu, Aug 17, 2023 at 3:09 AM LuKaRo <lists@xxxxxxxx> wrote:
Hi,
somehow, when using machinectl shell to access my nspawn containers, my .bashrc is ignored, although bash is correctly used as my shell. However, when specifying /bin/bash explicitly, the .bashrc gets sourced correctly. Any ideas?
lukas@home:~$ sudo machinectl shell x11 Connected to machine x11. Press ^] three times within 1s to exit session. [root@x11 ~]# echo $HISTFILESIZE; echo $0; 500 /bin/bash [root@x11 ~]# logout Connection to machine x11 terminated. lukas@home:~$ sudo machinectl shell x11 /bin/bash Connected to machine x11. Press ^] three times within 1s to exit session. root@x11:~# echo $HISTFILESIZE; echo $0; /bin/bash root@x11:~# exit Connection to machine x11 terminated. lukas@home:~$Thanks,
lukaro
--
Mantas Mikulėnas