Pcornel
Linux · Shell & Bash

.profile

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

Back to the Topic

Answer

~/.profile (or ~/.bash_profile if present) is read by login shells — SSH logins and console logins. It sets environment variables such as PATH and usually sources ~/.bashrc.

Remember

Bash reads only the first of ~/.bash_profile, ~/.bash_login, ~/.profile — an existing ~/.bash_profile means ~/.profile is ignored. Changes apply at the next login. Graphical sessions and systemd services may not read it at all.

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

login → /etc/profile → first of ~/.bash_profile, ~/.bash_login, ~/.profile → environment exported → ~/.bashrc sourced

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=2693

Confirmation

Confirm action

Continue?