Start a new interactive Bash from an existing terminal.
Do not start it as a login shell.
Which user file is normally read?
An interactive non-login Bash normally reads ~/.bashrc for aliases, prompts, and other interactive settings.
Detailed explanation
~/.bash_logoutIncorrect. .bash_logout is used when a login shell exits.
Incorrect. .bash_logout is used when a login shell exits.
~/.bashrcCorrect. ~/.bashrc is the usual startup file for an interactive non-login Bash.
Correct. ~/.bashrc is the usual startup file for an interactive non-login Bash.
~/.profileIncorrect. .profile is a login-shell candidate.
Incorrect. .profile is a login-shell candidate.
/etc/passwdIncorrect. /etc/passwd stores account data and is not a Bash startup file.
Incorrect. /etc/passwd stores account data and is not a Bash startup file.
Try it yourself
An example you can run in a temporary verification environment.
bash --noprofile --rcfile /dev/null -ic 'printf "interactive=%s login=%s\n" "$-" "$(shopt -q login_shell && echo yes || echo no)"'Expected result
interactiveフラグiを含み、login=noKey points
- Interactive non-login Bash
- ~/.bashrc
- Interactive settings
Notes
- Environment: GNU Bash 5.2 / 一時シェル
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.