Pcornel
Linux · Shell & Bash

.bashrc

Cheat sheet · https://pcornel.dk/topic.php?topic=2692

Back to the Topic

Answer

~/.bashrc is read by every interactive non-login Bash (a new terminal window, bash). It holds aliases, functions, prompt and shell options.

Remember

Login shells (SSH, console) read ~/.profile or ~/.bash_profile instead; most distributions source ~/.bashrc from there. Keep output (echo) out of ~/.bashrc — it breaks scp/rsync. Test changes with source ~/.bashrc.

First checks

  • bash -x script.sh — trace each expanded command
  • bash -n script.sh — syntax check only
  • shellcheck script.sh — common bugs and quoting problems
  • echo $? — exit code of the last command

Verify in this order

interactive non-login shell starts → reads /etc/bash.bashrc then ~/.bashrc → aliases, functions and options set

Where it usually breaks

First mismatch in persistent intent → provider/parser/generator → kernel/userspace runtime → dependency/security context → logs/counters → consumer-visible read-back; preserve identity/native diagnostic/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=2692

Confirmation

Confirm action

Continue?