Recall & Review
beginner
What is the purpose of the
.bashrc file in Linux?The
.bashrc file runs commands and sets environment variables for interactive non-login shells, like when you open a new terminal window.Click to reveal answer
beginner
When is the
.bash_profile file executed?The
.bash_profile file runs commands and sets environment variables for login shells, such as when you log in to your Linux system via console or SSH.Click to reveal answer
intermediate
How can you make sure your
.bashrc settings are applied when you log in?You can add the line
source ~/.bashrc inside your .bash_profile so that the .bashrc file runs during login shells too.Click to reveal answer
beginner
What is the difference between a login shell and a non-login shell?
A login shell starts when you log in to your system (console, SSH). A non-login shell starts when you open a new terminal window inside your desktop session.
Click to reveal answer
beginner
Why might you put aliases and functions in
.bashrc instead of .bash_profile?Because aliases and functions are mainly used in interactive shells, putting them in
.bashrc ensures they are available every time you open a terminal window.Click to reveal answer
Which file is executed when you log in to a Linux system via SSH?
✗ Incorrect
The .bash_profile file runs for login shells like SSH sessions.
If you open a new terminal window in your desktop environment, which file is usually executed?
✗ Incorrect
New terminal windows usually start non-login shells that run .bashrc.
How can you ensure that .bashrc runs during login shells?
✗ Incorrect
Adding source ~/.bashrc inside .bash_profile runs .bashrc during login shells.
Which file is best for setting environment variables that should apply to all shell sessions?
✗ Incorrect
Environment variables for login shells are best set in .bash_profile.
What type of shell is started when you log in to your system?
✗ Incorrect
A login shell starts when you log in to your system.
Explain the roles of .bashrc and .bash_profile in managing your shell environment.
Think about when you open a terminal vs when you log in.
You got /3 concepts.
Describe how you would set up your shell so that aliases work both when you log in and when you open a new terminal window.
Remember which file runs in login and non-login shells.
You got /2 concepts.