Everywhere All articles Download Buy — $19

Where apps hide your files

.bash_profile vs .bashrc on macOS

Updated 2026-10-28 · 6 min read

~/.bash_profile and ~/.bashrc sit in your home folder, hidden, and a new Mac has neither. Since zsh became the default shell they only matter if you run bash, and then the login-shell rule decides which one is read.

The location

~/.bash_profile
~/.bashrc

Both live directly in your home folder, and on a fresh Mac neither exists. macOS does not create them, so if ls says "No such file", nothing is wrong: you create the file when you want it. The names start with a dot, so Finder hides them.

First check which shell you actually use, because the default is zsh:

echo $SHELL

Apple says that starting with macOS 10.15 the Mac uses zsh as the default login and interactive shell. If that prints /bin/zsh, .bash_profile and .bashrc do nothing for you. The zsh equivalent is ~/.zshrc, and the file for a Mac that nobody has configured yet may not exist either. Bash only reads these files when you run bash.

See what is already there

List the dot-files in your home folder, names only:

ls -a ~ | grep -E '^\.(bash|zsh|z?profile)'

On the Mac used for this guide there was no .bash_profile and no .bashrc, but there were .profile, .zprofile, .zshenv, .zshrc and a .bash_history (the history files hold your typed commands, so do not open or share them).

To show hidden files in Finder, press ⇧⌘. (Shift, Command, full stop) in your home folder. Press it again to hide them.

Which file does bash read?

This is the part that confuses people. The bash manual that ships on the Mac (man bash) says:

Terminal starts every new window and tab as a login shell: its settings say Shells open with: Default login shell, and it launches the shell through /usr/bin/login. So on a Mac ~/.bash_profile is the file that matters when you open a tab, and ~/.bashrc is skipped unless you load it yourself. That is the opposite of most Linux desktops, which is why Linux tutorials leave Mac users confused. Typing bash inside a zsh tab is the exception: that starts a non-login shell, which reads only ~/.bashrc. If you are unsure which kind you have, run shopt -q login_shell && echo login || echo not-login inside bash.

Two traps follow from the rules above. If ~/.bash_profile exists, bash ignores ~/.profile, so creating one can hide lines an installer put in ~/.profile; add [ -r ~/.profile ] && . ~/.profile to ~/.bash_profile if you need them. And a line you added to ~/.bashrc is not seen by a Terminal tab until something sources it.

The usual setup: one file that loads the other

Keep your settings in ~/.bashrc and make ~/.bash_profile pull it in:

if [ -r ~/.bashrc ]; then . ~/.bashrc; fi

Put that single line in ~/.bash_profile. Then both login and non-login shells see the same settings.

Create or edit the files safely

There is no app to quit: bash reads these files only when a new shell starts. Back up first if the file exists, then edit, then check:

  1. Back up: cp ~/.bash_profile ~/.bash_profile.backup (skip if the file does not exist yet).
  2. Create it if needed: touch ~/.bash_profile
  3. Open it in TextEdit: open -e ~/.bash_profile
  4. Add your line, for example alias ll='ls -la', and save as plain text.
  5. Open a new Terminal tab, or run source ~/.bash_profile, and test the change.

If a typo breaks your shell start-up, you can restore the backup with cp ~/.bash_profile.backup ~/.bash_profile. A typo usually just prints an error each time a new bash shell starts.

If the shell prints a zsh warning

The bash that ships with macOS prints a notice when an interactive shell starts, saying the default interactive shell is now zsh. Apple's support page says to silence it by adding this line to ~/.bash_profile or ~/.profile:

export BASH_SILENCE_DEPRECATION_WARNING=1

To make bash your default instead, Apple documents chsh -s followed by a path listed in /etc/shells, for example chsh -s /bin/bash. On macOS 13 or later the same choice is in System Settings > Users & Groups: Control-click your name, choose Advanced Options, and pick from the Login shell menu.

The bash that comes with macOS is old: on the Mac used for this guide, /bin/bash --version reports 3.2.57. Scripts written for bash 4 or 5 can fail on it. A newer bash from Homebrew lives under the Homebrew prefix, which is /opt/homebrew on Apple silicon and /usr/local on Intel.

Related files you will meet

FileWhat it is
/etc/profileSystem-wide start-up for login shells, read before your own files
/etc/bashrcSystem-wide interactive bash settings, loaded from /etc/profile; do not edit it
~/.bash_profileYour login-shell file
~/.bashrcYour non-login interactive file
~/.profileUsed by sh, and by bash only when .bash_profile and .bash_login are absent
~/.bash_logoutRun when a login shell exits, if it exists
~/.bash_sessions/Per-tab saved state from Terminal, see below
~/.bash_historyYour command history

The system files are owned by root and read-only (-r--r--r-- on the Mac used for this guide). Leave them alone and put your changes in your home folder.

The Terminal session folder

If you see a ~/.bash_sessions folder, it comes from /etc/bashrc_Apple_Terminal, which /etc/bashrc loads when bash runs inside Terminal. The comments in that file explain that it saves and restores per-tab state, can keep a separate command history per tab in that folder, and that creating an empty file named ~/.bash_sessions_disable turns the feature off. Treat the folder like a history file: it can hold commands you typed, so do not share it.

Why a normal search misses these files

Names that start with a dot are hidden, so Finder searches and Spotlight results leave them out. That includes backups such as .bash_profile.backup and old copies from a previous Mac.

Finding your shell files next time

Type bash_profile or .bashrc into Everywhere and it lists every copy of those names, including a forgotten .bash_profile.backup or a copy inside an old backup folder (copies in Documents or on an external drive appear once it has Full Disk Access). Check the folder column to tell your home folder's file from the others, then press ⌘↵ to reveal it in Finder. It matches file names only, not the lines inside the files.

Common questions

Where is .bash_profile on a Mac?

At ~/.bash_profile, directly in your home folder. It is hidden and does not exist until you create it with touch ~/.bash_profile.

Should I use .bash_profile or .bashrc on macOS?

Terminal starts login shells, and login shells read ~/.bash_profile, not ~/.bashrc. Put your settings in ~/.bashrc and have ~/.bash_profile source it.

Why is my .bash_profile ignored on a Mac?

Your default shell is probably zsh, which never reads it. Run echo $SHELL; if it prints /bin/zsh, edit ~/.zshrc instead.

How do I show hidden files like .bashrc in Finder?

Open your home folder in Finder and press Shift-Command-full stop (⇧⌘.). Press it again to hide them.

Find any file before you finish typing

Everywhere keeps track of every file on your Mac — including the folders Spotlight hides and drives you have unplugged. Free for a day, then $19 once.

Version 2.20.3 · macOS 13+ · 4.7 MB · notarised

Related

© 2026 Caretopia Network Private Limited Everywhere for Mac Buy a licence Articles Privacy Support