Bird
0
0

What is the main difference between .bashrc and .bash_profile files in Linux?

easy📝 Conceptual Q1 of 15
Linux CLI - Environment and Configuration
What is the main difference between .bashrc and .bash_profile files in Linux?
A<code>.bashrc</code> runs only once at system startup; <code>.bash_profile</code> runs every time a terminal opens
B<code>.bashrc</code> runs for interactive non-login shells; <code>.bash_profile</code> runs for login shells
C<code>.bashrc</code> is for system-wide settings; <code>.bash_profile</code> is for user-specific settings
D<code>.bashrc</code> is executed after <code>.bash_profile</code> in all cases
Step-by-Step Solution
Solution:
  1. Step 1: Understand shell types

    Login shells run when you log in; non-login shells run when you open a new terminal window.
  2. Step 2: Know file purposes

    .bash_profile runs for login shells; .bashrc runs for interactive non-login shells.
  3. Final Answer:

    .bashrc runs for interactive non-login shells; .bash_profile runs for login shells -> Option B
  4. Quick Check:

    Shell type determines file run = A [OK]
Quick Trick: Login shells use .bash_profile; terminals use .bashrc [OK]
Common Mistakes:
  • Confusing when each file runs
  • Thinking .bashrc runs only once
  • Assuming .bash_profile is system-wide

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes