0

Description

I have two Raspberry Pi OS 13 (Trixie) systems with identical Bash versions and identical /bin/bash binaries (verified with md5sum). On one system, running bash -l sources ~/.bashrc as expected; on the other, it does not.

Environment

  • OS: Raspberry Pi OS 13 (Trixie)
  • Bash version: identical on both machines
  • /bin/bash md5sum: identical

Steps to Reproduce

  1. Add the following line at the top of ~/.bashrc:
    date > ~/bashrc_test.log 
  2. Run:
    bash -l 
  3. Check whether the file exists:
    cat ~/bashrc_test.log 

Expected Behavior

~/.bashrc should always be sourced, creating/updating the log file on both machines.

Actual Behavior

  • Machine A: log file is created
  • Machine B: log file not created

I am trying to understand what is going on. Please advise what I can look for. Thanks

4
  • See the Bash manual. $HOME/.bashrc is not sourced when Bash is invoked as an interactive login shell. That file is sourced when Bash is invoked as an interactive non-login shell. Commented Dec 5 at 18:31
  • 4
    Bash when run as login shells doesn't source .bashrc by default, so your expected behaviour is incorrect. Some distros have a .profile which does source .bashrc, so that might be what's going on in one system. If you modified .profile in the other system, that would explain it. (If not .profile, then /etc/profile and the like) Commented Dec 5 at 18:31
  • Oh. you mean it is not supposed to read .bashrc. OK. Actually there is a .profile file in the 'good' machine that is calling .bashrc while in the other there is no such file. So, that explains it then. Unless .profile sources .bashrc it won't get sourced.Thanks Commented Dec 5 at 18:48
  • Use source ~/.bashrc or . ~/.bashrc Commented Dec 5 at 20:17

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.