Challenge - 5 Problems
Bash Startup Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output of this command sequence?
You have a .bash_profile that contains
echo "Profile loaded" and a .bashrc that contains echo "RC loaded". You start a new login shell. What will be printed?Attempts:
2 left
💡 Hint
Remember that login shells read .bash_profile and interactive shells read .bashrc.
✗ Incorrect
When you start a login shell, .bash_profile is read first. If it calls .bashrc, then both messages appear. Usually, .bash_profile sources .bashrc, so both messages print in order.
🧠 Conceptual
intermediate1:30remaining
Which file is read by a non-login interactive shell?
When you open a new terminal window in a graphical environment (like GNOME Terminal), which file does bash read?
Attempts:
2 left
💡 Hint
Non-login interactive shells read a different file than login shells.
✗ Incorrect
Non-login interactive shells read ~/.bashrc to load user configurations.
🔧 Debug
advanced2:00remaining
Why does a command in .bashrc not run on login?
You added
echo "Hello from .bashrc" to your ~/.bashrc but it does not print when you login via SSH. Why?Attempts:
2 left
💡 Hint
Think about which files login shells read.
✗ Incorrect
Login shells read .bash_profile or .profile, not .bashrc by default. To run .bashrc commands on login, .bash_profile must source .bashrc.
🚀 Application
advanced2:30remaining
How to ensure .bashrc runs on login shells?
You want your .bashrc commands to run every time you login (including SSH). Which snippet should you add to your ~/.bash_profile?
Attempts:
2 left
💡 Hint
You want to run .bashrc only if it exists.
✗ Incorrect
The common practice is to check if .bashrc exists and source it in .bash_profile to run .bashrc commands on login shells.
💻 Command Output
expert2:00remaining
What is the output of this .bash_profile snippet?
Given this ~/.bash_profile content:
echo "Start" if [ -f ~/.bashrc ]; then . ~/.bashrc fi echo "End"And ~/.bashrc contains:
echo "Inside RC"What is printed when you login?
Attempts:
2 left
💡 Hint
Commands run in order as the shell reads the files.
✗ Incorrect
The .bash_profile prints "Start", then sources .bashrc which prints "Inside RC", then prints "End".