Mission 29 of 30
Customizing Your Shell Safely
Try a shell customization with a tested rollback path.
Experiment with aliases, prompt changes, and sourced files inside the sandbox before touching .bashrc.
Practice inside
~/linux-practice. Check your setup before you begin.
Prerequisite: Locating Files and Reading Documentation
.
What you’ll practice
- Temporarily change PS1
- Source a practice alias file
- Understand .bashrc without editing it
The mental model
- .bashrc runs for interactive Bash shells.
- Temporary PS1 changes vanish when you close the shell or source defaults.
- Practice customization in ~/linux-practice first.
Try it in your terminal
Inspect, do not edit
Read-only system viewReads the beginning of your real .bashrc without changing it.
Run from ~/linux-practice
cat ~/.bashrc | head -30 Temporary prompt
Safe in practice folderChanges and restores the prompt only in the current shell.
Run from ~/linux-practice
OLD_PS1=$PS1
PS1='Practice> '
echo 'Prompt changed for this session'
PS1=$OLD_PS1 Practice alias file
Safe in practice folderSources aliases from a removable practice file.
Run from ~/linux-practice
echo "alias showdate='date +%Y-%m-%d'" >> ~/linux-practice/my_aliases
source ~/linux-practice/my_aliases
showdate
unalias showdate Real .bashrc edit example
Explanation onlyThis permanently modifies your real shell startup file. Explanation only in this course.
Run from do not run
echo "alias la='ls -A'" >> ~/.bashrc Put it into practice
- Create a practice alias file with one alias and source it.
- Remove the alias with unalias.
Check your result
The customization works and the original state can be restored.
Common mistakes
- You experiment by appending `echo 'alias foo=...' >> ~/.bashrc` over and over. After ten tries, your .bashrc has ten duplicate lines and three broken aliases. Test in the current session first. Write to .bashrc once, when you know it's right.
- You put `source somefile.sh` in your .bashrc without reading what's in it. The source command runs every line in that file as if you typed it yourself. A malicious or buggy sourced file can break your shell or worse. Only source files you've inspected.
Check your understanding
Explain these in your own words. If you’re unsure, revisit the examples before moving on.
- Why use ~/linux-practice/my_aliases first?
- What does source do?
Your practice, your pace
Loading saved progress…