Start Bash as a login shell.
~/.bash_profile, ~/.bash_login, and ~/.profile all exist.
Which user file is read after /etc/profile?
A login Bash searches ~/.bash_profile, ~/.bash_login, and ~/.profile in that order and reads only the first existing file.
Detailed explanation
~/.profileIncorrect. ~/.profile is considered only when the earlier candidates do not exist.
Incorrect. ~/.profile is considered only when the earlier candidates do not exist.
~/.bash_profileCorrect. ~/.bash_profile is the first candidate and is the only one read in this case.
Correct. ~/.bash_profile is the first candidate and is the only one read in this case.
~/.bash_loginIncorrect. ~/.bash_login is the next candidate after ~/.bash_profile.
Incorrect. ~/.bash_login is the next candidate after ~/.bash_profile.
~/.bashrcIncorrect. ~/.bashrc is normally for interactive non-login Bash.
Incorrect. ~/.bashrc is normally for interactive non-login Bash.
Try it yourself
An example you can run in a temporary verification environment.
bash --noprofile --norc -c 'help source >/dev/null; printf "%s\n" "$BASH_VERSION"'Expected result
検証に使用するBashのバージョンKey points
- The three candidates are not all read
- .bash_profile has priority
- .bashrc is a different startup path
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.