Home > Wiki Tips

Bash Profile Mac: What Is it and How it Differs from Bashrc?

Updated on Friday, June 14, 2024

iBoysoft author Anna Yuan

Written by

Anna Yuan
Professional tech editor

Approved by

Jessica Shee

English Deutsch

Summary: This post will tell you what is Bash and What is bash profile on Mac. It also lists how to create, edit, and delete bash profile on Mac.

bash profile on Mac

When you're working with macOS, sometimes you may encounter the 'source ~/.bash_profile: command not found' error in the Terminal app. Then, you may wonder what is bash profile on Mac and how to use it. Want to know more about bash profile on Mac, just keep reading.

What is Bash

Before learning what the bash profile on Mac is, it's necessary to know what Bash is first. Bash is a Unix shell and command language for the GNU operating system. The name is an acronym for the Bourne Again Shell, a pun on Stephen Bourne, the author of the direct ancestor of the current Unix shell.

what is Bash

Bash has been used as the default login shell for most Linux distributions. It is also available for the Windows platform. In addition, Bash was also the default shell in macOS Mojave and earlier. Until the release of macOS Catalina, Apple changes the default shell to Zsh and Bash still remains available as an alternative shell.You can change zsh to bash on Mac if needed.

What is bash_profile on Mac

In simple words, bash_profile is a configuration file for the Bash shell, which is a hidden file in your Mac's user directory. The bash profile on Mac has loaded before Terminal loads your shell environment and contains all the startup configuration and preferences for your command-line interface. Within it, you can change your Terminal prompt, change the colors of text, add aliases to functions you use all the time, and so much more.

The bash profile on Mac is an incredibly powerful tool that can make the Terminal app infinitely easier and quicker to use. It can improve your efficiency, help you avoid time-wasting errors, and just look really pretty on your screen.

what is bash profile on Mac

Bash_profile vs. Bashrc

When talking about the bash_profile on Mac, another Bash config file may appear in your mind - bashrc. The two files look very similar, so do you know what's the difference between bash profile and bashrc?

Bash_profile and bashrc are both files containing shell commands that are run when Bash is invoked. Bash profile is executed for login shells, while .bashrc is executed for interactive non-login shells.

How to create .bash_profile in Mac

If you want to create the bash profile in Mac, just follow the below steps:

  1. Open Launchpad > Other > Terminal.
  2. Type in the following command to move the home directory and press Enter: cd ~/
  3. Input the below touch command to create the bash_profile on Mac:touch .bash_profile

How to edit .bash_profile on Mac

For common Mac users, it's not recommended to edit bash_profile on Mac by yourself since any incorrect changes may cause troubles on your Mac computer. But if you're an advanced Mac user and want to edit the bash profile on Mac, try the below methods.

To edit the .bash_profile inside the Terminal, you can use the vi command as follows:

vi ~/.bash_profile

But If the Mac bash_profile is too large, then it becomes difficult to edit in the Terminal itself. So you can use TextEdit to edit bash_profile in such cases. 

  1. Open a plain text editor i.e. TextEdit.
  2. Press Command + O to open the file.
  3. Move to your home directory.
  4. There might be chances that your bash_profile is hidden in the home directory and you will not be able to see that file. Press Command + Shift + Period (.) to see the hidden file.
  5. Select .bash_profile, fix your problem and save it accordingly.

Alternatively, you can use the following simple command line to open and edit the bash_profile:open -a TextEdit.app ~/.bash_profile

How to delete bash profile on Mac

To delete bash_profile on Mac, it's quite simple:

  1. Open Finder on your Mac.
  2. Go to the user's home directory. 
  3. Check if the bash_profile is visible there or not. If not, press Command + Shift + Period (.) and bash_profile will be visible. Select the bash_profile and move it to Mac Trash.