Use it to set environment variables for a user's login sessions, or when PATH changes are missing after login.
.profile
1. Which file exists: ls -a ~ | grep -E 'bash_profile|profile'?
2. Variable in the right file? grep PATH ~/.profile ~/.bash_profile.
3. Log in again (or bash -l) and check echo $PATH.
4. ~/.bashrc sourced from it?
5. Services need their own Environment= settings.
login → /etc/profile → first of ~/.bash_profile, ~/.bash_login, ~/.profile → environment exported → ~/.bashrc sourced
For Shell & Bash → .profile, continue with the first unproven Topic check: Identify the actual login/session creator and shell, then trace which startup file wins. If that boundary is healthy, advance to the adjacent check: Check whether ~/.bash_profile/~/.bash_login exists and whether it sources ~/.profile or ~/.bashrc. Preserve the same host/time/identity scope and rerun the original workload before accepting recovery.
Continue only after interpreting the current observation.Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Operational evidence path Verify boundary
login/session creation → shell selection/invocation → system login files → user login file precedence → exports/commands → inherited process environment → consumer behavior
Healthy evidence: the real login/session startup chain is identified, a fresh session receives the intended environment and unrelated service/job contexts use their own configuration.
Step 2 Verification and output interpretation Verify boundary
Existing fast checks for this Topic. - Identify the actual login/session creator and shell, then trace which startup file wins.
- Check whether ~/.bash_profile/~/.bash_login exists and whether it sources ~/.profile or ~/.bashrc.
- Create a fresh login/session of the same type and inspect effective environment from the intended consumer.
- Keep service/automation environment in its owning configuration rather than relying on interactive login profiles.
Verification chain. login/session creation → shell selection/invocation → system login files → user login file precedence → exports/commands → inherited process environment → consumer behavior
Step 3 Commands Verify boundary
cat ~/.profile ~/.bash_profile 2>/dev/null
Step 4 Failure modes and next checks Narrow the fault
Suspicious evidence: operators edit .profile for a service or non-login shell, Bash precedence skips it, or current inherited environment is mistaken for fresh-session evidence.
.profile verification shows environment initialization only for a matching fresh session path; it does not establish service, cron or non-login shell environment.
Step 5 Common mistakes Narrow the fault
- Expecting .bashrc settings in login shells without sourcing it.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
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.
bash -x script.sh— trace each expanded commandbash -n script.sh— syntax check onlyshellcheck script.sh— common bugs and quoting problemsecho $?— exit code of the last command
ReferenceWhat it is1 section · depth on demand
Core model
Treat .profile as one candidate in a shell/session-specific startup chain, not a universal environment registry. Bash login shells prefer ~/.bash_profile or ~/.bash_login before ~/.profile; non-login interactive shells normally do not read it directly.
ReferenceImportant terms & boundaries5 sections · depth on demand
What this shows and what it does not
.profile verification shows environment initialization only for a matching fresh session path; it does not establish service, cron or non-login shell environment.
Environment Variables owns process inheritance; .bashrc owns common interactive Bash startup; systemd & Services/Scheduling own service/job environment.
In depth
~/.profile and ~/.bash_profile: login-time settings
Login shells read profile files once per login, and everything started from that session inherits what they set. The bash(1) manual page describes the order:
/etc/profilefirst.- Then only the first readable file of
~/.bash_profile,~/.bash_loginand~/.profile. ~/.bash_logoutwhen a login shell exits.
When Bash is started as sh, it reads /etc/profile and ~/.profile only.
Which file to use
| File | Read by | Use for |
|---|---|---|
/etc/profile, /etc/profile.d/*.sh | All login shells (Bash and sh) | System-wide environment |
~/.bash_profile | Bash login shells only | Bash-specific login settings; source ~/.bashrc |
~/.profile | Bash (if no .bash_profile), sh, dash and display managers | Portable environment: PATH, EDITOR, LANG |
~/.bashrc | Interactive non-login Bash | Aliases, prompt, functions |
If ~/.bash_profile exists, Bash ignores ~/.profile. Settings put in ~/.profile then silently stop working, which is a frequent surprise after a tool creates .bash_profile.
A standard ~/.bash_profile
host$ cat ~/.bash_profile
# Environment for all login sessions
[ -f ~/.profile ] && . ~/.profile
# Interactive settings
[ -f ~/.bashrc ] && . ~/.bashrc
host$ cat ~/.profile
export EDITOR=vim
export PATH="$HOME/.local/bin:$PATH"
export LANG=en_DK.UTF-8
host$ bash -lc 'echo $EDITOR; echo $PATH | tr : "\n" | head -2'
vim
/home/alice/.local/bin
/usr/local/sbin
host$ ls /etc/profile.d/
bash_completion.sh vte-2.91.sh
Environment for services
Profile files only affect shells. systemd services, cron jobs and desktop applications started outside a shell don't read them. Give services their environment with Environment= or EnvironmentFile= in the unit, and put the variables for cron in the crontab itself.
Seeing the effect
Changes to profile files apply at the next login. To test without logging out, start a login shell with bash -l, as in the example. Or source the file into the current shell with . ~/.profile.
Documented example, not captured output.
How it works at runtime
.profile is part of Shell & Bash → .profile. .profile is a conventional per-user login-session initialization file used by Bourne-compatible shells when their shell-specific login file does not supersede it; desktop/session managers may also source it differently.
Topic-specific state model. .profile is a conventional per-user login-session initialization file used by Bourne-compatible shells when their shell-specific login file does not supersede it; desktop/session managers may also source it differently.
Interpretation rule. - Editing ~/.profile ≠ an existing process environment changes.
- ~/.profile ≠ guaranteed to run for every terminal, SSH command, service, cron job or desktop session.
- Export in .profile ≠ systemd service receives the variable unless its manager/service environment is configured accordingly.
- Login-shell startup ≠ non-login interactive startup.
Quick reference
Login shells (SSH logins, console, su -, bash -l) read /etc/profile and /etc/profile.d/*.sh, then the first of ~/.bash_profile, ~/.bash_login, ~/.profile. Most setups source ~/.bashrc from ~/.bash_profile so both shell types behave the same.
| Shell type | Reads |
|---|---|
| Login interactive | /etc/profile, ~/.bash_profile (→ ~/.bashrc) |
| Non-login interactive | ~/.bashrc |
| Non-interactive (scripts, cron) | $BASH_ENV only |
That is why cron jobs and systemd services do not see variables set in your profile.
Limits and how it fails
Primary failure point. .profile verification shows environment initialization only for a matching fresh session path; it does not establish service, cron or non-login shell environment.
ReferenceConfiguration & state1 section · depth on demand
Configuration, persistence and lifecycle
Distribution/platform context. Environment Variables owns process inheritance; .bashrc owns common interactive Bash startup; systemd & Services/Scheduling own service/job environment.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Shell & Bash → .profile. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://www.gnu.org/software/bash/manual/bash.html · confidence 94%What changed and what may be affected
Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.
Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.
Quick lookup tables
.profile operational reference
Topic-specific lookup boundaries, proof limits and next-step Evidence for .profile.
| Lookup boundary | Topic-specific reference | Operational use |
|---|---|---|
| Scope / effective state | .profile is a conventional per-user login-session initialization file used by Bourne-compatible shells when their shell-specific login file does not supersede it; desktop/session managers may also source it differently. | Establish exactly what this Topic owns before crossing into another subsystem. |
| Fast verification | Pin host/distribution + shell/version/mode → identify cwd/mount namespace + input/path/stream → preserve quoting/expansion and final argv → map fd/pipeline/process boundaries → inspect object/variable/status/signal state → make one minimal reversible change → read back effective state → repeat original consumer/script/workload test. | Use the shortest evidence path first; a fast check is a boundary test, not blanket proof. |
| Verification chain | login/session creation → shell selection/invocation → system login files → user login file precedence → exports/commands → inherited process environment → consumer behavior | Trace requested/configured state through effective state to the observed workload result. |
| Failure boundary | .profile verification proves environment initialization only for a matching fresh session path; it does not establish service, cron or non-login shell environment. | Stop broad troubleshooting at the first boundary that is not supported by evidence. |
| Positive evidence | Correlated Linux file/text/shell evidence can establish this proof path: login/session creation → shell selection/invocation → system login files → user login file precedence → exports/commands → inherited process environment → consumer behavior | Use this observation only for the specific claim it actually supports. |
| Evidence limit | It does not independently prove behavior outside the captured host, shell/session, cwd/namespace, input, process, filesystem, locale, time or workload scope. .profile verification proves environment initialization only for a matching fresh session path; it does not establish service, cron or non-login shell environment. | Do not promote a local success signal into end-to-end or adjacent-dependency proof. |
| Next troubleshooting check | Continue from the first unproven boundary: capture the exact shell-delivered argv/streams or resolved object, verify the effective target state, change only the demonstrated cause, then repeat the original consumer/script/workload and adjacent regression checks. | Continue to the next unresolved boundary while preserving the original test condition. |
.profile · operational reference
Compact Linux state, persistence, verification and boundary reference for fast lookup.
| Reference boundary | .profile |
|---|---|
| Topic path | Shell & Bash → .profile |
| Runtime state | .profile is a conventional per-user login-session initialization file used by Bourne-compatible shells when their shell-specific login file does not supersede it; desktop/session managers may also source it differently. |
| Fast checks | - Identify the actual login/session creator and shell, then trace which startup file wins. - Check whether ~/.bash_profile/~/.bash_login exists and whether it sources ~/.profile or ~/.bashrc. - Create a fresh login/session of the same type and inspect effective environment from the intended consumer. - Keep service/automation environment in its owning configuration rather than relying on interactive login profiles. |
| Verification chain | login/session creation → shell selection/invocation → system login files → user login file precedence → exports/commands → inherited process environment → consumer behavior Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return/regression → explicit Evidence boundary. Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return path or regression → explicit Evidence boundary. |
| Failure boundary | .profile verification proves environment initialization only for a matching fresh session path; it does not establish service, cron or non-login shell environment. Boundary chain: process/context → userspace configuration → kernel subsystem/resource → device/network/filesystem dependency → effective state → original workload. |
| Persistence rule | Prove which configuration source owns the state, then prove that the running consumer loaded or generated the intended state. |