Pcornel
Browse topics
Options
Recent
Favorites
Linux · Technical reference

.profile

Direct 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.

When to use this

Use it to set environment variables for a user's login sessions, or when PATH changes are missing after login.

First 30 seconds

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.

Operational verification

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

Evidence · next step

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
Platform / version applicability
linux
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

Platformlinux
Scope / prerequisiteUse it to set environment variables for a user's login sessions, or when PATH changes are missing after login.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

5 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

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 references

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.

observation · 1
Key points

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.

Key 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
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/profile first.
  • Then only the first readable file of ~/.bash_profile, ~/.bash_login and ~/.profile.
  • ~/.bash_logout when a login shell exits.

When Bash is started as sh, it reads /etc/profile and ~/.profile only.

Which file to use

FileRead byUse for
/etc/profile, /etc/profile.d/*.shAll login shells (Bash and sh)System-wide environment
~/.bash_profileBash login shells onlyBash-specific login settings; source ~/.bashrc
~/.profileBash (if no .bash_profile), sh, dash and display managersPortable environment: PATH, EDITOR, LANG
~/.bashrcInteractive non-login BashAliases, 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.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

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 typeReads
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.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

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
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor doclinux current

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%
Technical changelog & impact

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.

Related reference impactReview these references after material technical changes when their shared boundary is affected.
Terminology layer

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.

Aliases that resolve here
profile linux~/.profilebash login profilelinux login environment
Embedded reference data

Quick lookup tables

.profile operational reference

Topic-specific lookup boundaries, proof limits and next-step Evidence for .profile.

Lookup boundaryTopic-specific referenceOperational 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 verificationPin 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 chainlogin/session creation → shell selection/invocation → system login files → user login file precedence → exports/commands → inherited process environment → consumer behaviorTrace 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 evidenceCorrelated 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 behaviorUse this observation only for the specific claim it actually supports.
Evidence limitIt 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 checkContinue 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 pathShell & 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 chainlogin/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 ruleProve which configuration source owns the state, then prove that the running consumer loaded or generated the intended state.
Confirmation

Confirm action

Continue?