Start a new interactive Bash that is not a login shell.
Define an alias for this user only.
Which file is normally read?
An interactive non-login Bash reads ~/.bashrc. It is commonly used for aliases, prompts, and other interactive settings.
Detailed explanation
/etc/profileIncorrect. /etc/profile is for login-shell initialization.
Incorrect. /etc/profile is for login-shell initialization.
~/.profileIncorrect. ~/.profile is a login-shell startup candidate.
Incorrect. ~/.profile is a login-shell startup candidate.
~/.bashrcCorrect. ~/.bashrc is read by an interactive non-login Bash for user settings.
Correct. ~/.bashrc is read by an interactive non-login Bash for user settings.
~/.bash_logoutIncorrect. ~/.bash_logout is for login-shell exit processing.
Incorrect. ~/.bash_logout is for login-shell exit processing.
Try it yourself
An example you can run in a temporary verification environment.
bash --noprofile --rcfile /dev/null -ic 'case $- in *i*) echo interactive;; esac; shopt -q login_shell || echo non-login'Expected result
interactiveとnon-loginKey points
- Interactive non-login shell
- ~/.bashrc
- Aliases and prompt 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.