The main difference with shell config files is that some are only read by "login" shells (eg. when you login from another host, or login at the text console of a local unix machine). these are the ones called, say, .login or .profile or .zlogin (depending on which shell you're using).

Then you have config files that are read by "interactive" shells (as in, ones connected to a terminal (or pseudo-terminal in the case of, say, a terminal emulator running under a windowing system). these are the ones with names like .bashrc, .tcshrc, .zshrc, etc.

bash complicates this in that .bashrc is only read by a shell that's both interactive and non-login, so you'll find most people end up telling their .bash_profile to also read .bashrc with something like

[[ -r ~/.bashrc ]] && . ~/.bashrc

Other shells behave differently - eg with zsh, .zshrc is always read for an interactive shell, whether it's a login one or not.

The manual page for bash explains the circumstances under which each file is read. Yes, behaviour is generally consistent between machines.

.profile is simply the login script filename originally used by /bin/sh. bash, being generally backwards-compatible with /bin/sh, will read .profile if one exists.

Answer from Cos on Stack Overflow
🌐
Stack Overflow
stackoverflow.com › questions › 415403 › whats-the-difference-between-bashrc-bash-profile-and-environment
shell - What's the difference between .bashrc, .bash_profile, and .environment? - Stack Overflow

The main difference with shell config files is that some are only read by "login" shells (eg. when you login from another host, or login at the text console of a local unix machine). these are the ones called, say, .login or .profile or .zlogin (depending on which shell you're using).

Then you have config files that are read by "interactive" shells (as in, ones connected to a terminal (or pseudo-terminal in the case of, say, a terminal emulator running under a windowing system). these are the ones with names like .bashrc, .tcshrc, .zshrc, etc.

bash complicates this in that .bashrc is only read by a shell that's both interactive and non-login, so you'll find most people end up telling their .bash_profile to also read .bashrc with something like

[[ -r ~/.bashrc ]] && . ~/.bashrc

Other shells behave differently - eg with zsh, .zshrc is always read for an interactive shell, whether it's a login one or not.

The manual page for bash explains the circumstances under which each file is read. Yes, behaviour is generally consistent between machines.

.profile is simply the login script filename originally used by /bin/sh. bash, being generally backwards-compatible with /bin/sh, will read .profile if one exists.

Answer from Cos on stackoverflow.com
Discussions

terminal - What is the difference between .bash_profile and .bashrc? - Ask Different

🌐 apple.stackexchange.com
May 10, 2012
To make an alias for the Terminal in OS X, you can either put the aliases in .bash_profile or .bashrc. What is the difference between the two and why would I choose to put aliases in one and not the More on apple.stackexchange.com

bash_profile or bashrc??

🌐 r/linux4noobs
4
March 4, 2022
.bash_profile is read and executed when Bash is invoked as an interactive login shell, while .bashrc is executed for an interactive non-login shell. Basically, use .bash_profile for things that should run just once after login (there is not much sense setting PATH each time you open the new shell, for example, as it will be inerited anyway). .bashrc for things you want to start always. More on reddit.com

bash_profile or bashrc?? : linux4noobs

🌐 r/linux4noobs
What is the difference between bash_profile and bashrc environment variables? More on old.reddit.com

ELI5 - Ubuntu - .bashrc, .profile, .bash_profile : I'm not getting where I'm meant to add what to when where - I want to create a custom command based on a Python script I wrote : linux4noobs

🌐 r/linux4noobs
How do, there's a lot of stuff about these but I can't quite seem to grasp what they're saying! Basically I have a script that I've written, and... More on old.reddit.com
Videos
December 16, 2012
7.66K
March 14, 2019
6.54K
November 6, 2019
6.23K
🌐
Linuxize
linuxize.com › post › bashrc-vs-bash-profile
.bashrc vs .bash_profile | Linuxize
May 10, 2020 - Use .bash_profile to run commands that should run only once, such as customizing the $PATH environment variable . Put the commands that should run every time you launch a new shell in the .bashrc file.
🌐
Super User
superuser.com › questions › 789448 › choosing-between-bashrc-profile-bash-profile-etc
unix - Choosing between .bashrc, .profile, .bash_profile, etc - Super User

TL;DR:

  • ~/.bash_profile should be super-simple and just load .profile and .bashrc (in that order)

  • ~/.profile has the stuff NOT specifically related to bash, such as environment variables (PATH and friends)

  • ~/.bashrc has anything you'd want at an interactive command line. Command prompt, EDITOR variable, bash aliases for my use

A few other notes:

  • Anything that should be available to graphical applications OR to sh (or bash invoked as sh) MUST be in ~/.profile

  • ~/.bashrc must not output anything

  • Anything that should be available only to login shells should go in ~/.profile

  • Ensure that ~/.bash_login does not exist.

Answer from Dan Rabinowitz on superuser.com
🌐
Stack Exchange
apple.stackexchange.com › questions › 51036 › what-is-the-difference-between-bash-profile-and-bashrc
terminal - What is the difference between .bash_profile and .bashrc? - Ask Different

.bash_profile is executed for login shells, while .bashrc is executed for interactive non-login shells.

When you login (type username and password) via console, either sitting at the machine, or remotely via ssh: .bash_profile is executed to configure your shell before the initial command prompt.

But, if you’ve already logged into your machine and open a new terminal window (xterm) then .bashrc is executed before the window command prompt. .bashrc is also run when you start a new bash instance by typing /bin/bash in a terminal.

On OS X, Terminal by default runs a login shell every time, so this is a little different to most other systems, but you can configure that in the preferences.

Answer from Alex on apple.stackexchange.com
🌐
Reddit
reddit.com › r/linux4noobs › bash_profile or bashrc??
r/linux4noobs on Reddit: bash_profile or bashrc??

.bash_profile is read and executed when Bash is invoked as an interactive login shell, while .bashrc is executed for an interactive non-login shell. Basically, use .bash_profile for things that should run just once after login (there is not much sense setting PATH each time you open the new shell, for example, as it will be inerited anyway). .bashrc for things you want to start always.

Find elsewhere
🌐
RedSwitches
redswitches.com › home › operating systems › the major differences between bashrc vs bash_profile in linux
Difference Between Bashrc Vs Bash_profile In Linux
February 27, 2025 - Some everyday use cases for .bashrc ... other preferences for an individual’s interactive shell experience. The .bash_profile file is often used for configurations related to the login process....
🌐
Ask Ubuntu
askubuntu.com › questions › 1411833 › what-goes-in-profile-and-bashrc
What goes in ~/.profile and ~/.bashrc? - Ask Ubuntu

It helps to understand which files get sourced, when, and why.

  • .profile is sourced by a login shell on startup. Typically, the only login shell you start is the one started when you log in, but you can run a login shell at any time with bash -l. (Also, on macOS, there is no initial login shell, so terminal emulators tend to run a login shell for each new window.)

  • .profile is an ideal place to set environment variables that can be inherited by any program started from the login shell.

  • .bashrc, on the other hand, is sourced by non-login interactive shells, such as those started by terminal windows (most configs also source .bashrc in interactive login shells though). This is where you set things specific to your interactive shell that aren't otherwise inherited from the parent process. For example, PS1 is set here because only interactive shells care about its value, and any interactive shell will source .bashrc anyway, so there is no need to define and export PS1 from .profile.

  • And though you didn't ask, it's worth pointing out the difference between .profile and .bash_profile here. .profile is "shared" by all POSIX shells (such as dash), so don't put anything bash-specific here. .bash_profile, though, is only used by bash, so you can use bash extensions in it. If .bash_profile is present, .profile will be ignored, so if for whatever reason you want to use both, you can add . ~/.profile to the top of your .bash_profile.

Answer from chepner on askubuntu.com
🌐
GeeksforGeeks
geeksforgeeks.org › linux-unix › bashrc-vs-bash_profile-what-is-the-difference
bashrc vs. bash_profile: What Is the Difference? - GeeksforGeeks
January 29, 2024 - Let’s clarify that the “.bashrc” and “.bash_profile” files are exclusive to Unix-based operating systems such as Linux and macOS. If you are using the Windows operating system, you won’t find these files on your system. In Linux or macOS, they are located in the “/home/yourusername” ...
🌐
Joshstaiger
joshstaiger.org › archives › 2005 › 07 › bash_profile_vs.html
.bash_profile vs .bashrc | Josh Staiger ☙
When you login (type username and password) via console, either sitting at the machine, or remotely via ssh: .bash_profile is executed to configure your shell before the initial command prompt. But, if you’ve already logged into your machine and open a new terminal window (xterm) inside Gnome ...
🌐
Tutorialspoint
tutorialspoint.com › home › articles on trending technologies › difference between .bashrc and .bash_profile
Difference Between .bashrc and .bash_profile
April 11, 2023 - Bashrc is used to set environment variables, define aliases, and create functions. It's also used to customize prompt that appears in your terminal. Bash_profile is another configuration file for Bash shell, but it's executed only once when you log in to your account.
🌐
Lei Mao's Log Book
leimao.github.io › blog › bashrc-VS-profile-VS-bash_profile
~/.bashrc VS ~/.profile VS ~/.bash_profile - Lei Mao's Log Book
October 26, 2020 - There are many other shell executable variants, such as zsh. ~/.bashrc is only specific to bash. There are many settings in the ~/.bashrc that makes the shell look colorful. For example, The comment block found in the ~/.profile explicitly tells us that it will be executed for the login shells.
🌐
GitHub
gist.github.com › korya › bd0de47f36dbb5c29a90
.bashrc vs .bash_profile · GitHub
.bashrc vs .bash_profile. GitHub Gist: instantly share code, notes, and snippets.
🌐
Iamsorush
iamsorush.com › posts › linux-bashrc-profile
What is the difference between .bashrc, .bash_profile, and .profile?
August 9, 2022 - The start-up Bash commands, variables, aliases and cutomizations are put in .bashrc, .bash_profile, and .profile files. So whenever you open a new terminal, one of these files is sourced first, but which one?
🌐
Server Fault
serverfault.com › questions › 261802 › what-are-the-functional-differences-between-profile-bash-profile-and-bashrc
linux - What are the functional differences between .profile .bash_profile and .bashrc - Server Fault

.bash_profile and .bashrc are specific to bash, whereas .profile is read by many shells in the absence of their own shell-specific config files. (.profile was used by the original Bourne shell.) .bash_profile or .profile is read by login shells, along with .bashrc; subshells read only .bashrc. (Between job control and modern windowing systems, .bashrc by itself doesn't get used much. If you use screen or tmux, screens/windows usually run subshells instead of login shells.)

The idea behind this was that one-time setup was done by .profile (or shell-specific version thereof), and per-shell stuff by .bashrc. For example, you generally only want to load environment variables once per session instead of getting them whacked any time you launch a subshell within a session, whereas you always want your aliases (which aren't propagated automatically like environment variables are).

Other notable shell config files:

/etc/bash_profile (fallback /etc/profile) is read before the user's .profile for system-wide configuration, and likewise /etc/bashrc in subshells (no fallback for this one). Many systems including Ubuntu also use an /etc/profile.d directory containing shell scriptlets, which are . (source)-ed from /etc/profile; the fragments here are per-shell, with *.sh applying to all Bourne/POSIX compatible shells and other extensions applying to that particular shell.

Answer from geekosaur on serverfault.com
🌐
Medium
medium.com › @shalinpatel. › difference-between-bashrc-bash-profile-and-profile-1947edea4318
Difference Between .bashrc, .bash-profile, and .profile | by Shalin Patel | Medium
January 5, 2024 - Bash shell uses a few startup files to set up the environment. These files determine certain Bash shell configurations for the shell itself and system users. In this tutorial, we’ll learn about a few…
🌐
LinuxToday
linuxtoday.com › home › understanding the difference between bashrc and bash_profile
Understanding the Difference Between bashrc and bash_profile
May 9, 2025 - Understanding the difference between bashrc and bash_profile can help you customize and optimize your bash shell environment. Learn about their distinctions and how to leverage their functionalities effectively.
🌐
Quora
quora.com › Should-I-put-most-of-my-environment-settings-in-bashrc-or-bash_profile
Should I put most of my environment settings in .bashrc or .bash_profile? - Quora
Answer (1 of 4): Let's learn when .bash_profile and .bashrc are called ... For account postgres, I configure the two files as such ... .bash_profile: [code]echo 'running .bash_profile' [/code].bashrc: [code]echo 'running .bashrc' [/code]Result: [code]$ ssh postgres@localhost running .bash_pr...
🌐
Namehero
namehero.com › blog › bashrc-vs-bash_profile-a-complete-guide
Bashrc vs. bash_profile: A Complete Guide
February 19, 2025 - Learn the difference between bashrc vs. bash_profile and how you can use these different commands in the Linux command line.
🌐
Tutorialspoint
tutorialspoint.com › home › articles on trending technologies › difference between .bashrc, .bash_profile, and .profile
Difference Between .bashrc, .bash_profile, and .profile
January 25, 2023 - Discover the distinctions between .bashrc, .bash_profile, and .profile to optimize your shell settings in Unix/Linux.