I want to know which file to edit in order to launch my .bash_profile when I graphically start the terminal.

I am using an AWS Workspace with the following OS and the default MATE terminal.

$ cat /etc/os-release

NAME="Amazon Linux"
ID_LIKE="centos rhel fedora"
PRETTY_NAME="Amazon Linux 2"

There are so many files in ~/etc:

    #lots of .sh

But in my /home/<usr> directory I have:


^ I created this bash_profile file and it works when I launch the terminal graphically and do $ source ~/.bash_profile

REQUESTED EDIT: This is what I am putting in my .bash_profile it colors my command prompt on every line and adds a timestamp and mentions the virtualenv I have active. I expect it to

# in order to be able to change the color of venv prompt
function virtualenv_info(){
    # Get Virtual Env
    if [[ -n "$VIRTUAL_ENV" ]]; then
        # Strip out the path and just leave the env name
        # In case you don't have one activated
    [[ -n "$venv" ]] && echo "(pvenv:$venv) "

# disable the default virtualenv prompt change


git_branch() {
  git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/<b:\1>/'

# set the prompt color
# color starts with `\e[36m` and is closed with `\e[0m`
export PS1="\e[36m[\t] \e[38;5;203m${VENV}\e[38;5;78m\$(git_branch) \e[38;5;179m\w \e[0m☯  "

enter image description here

WORKAROUND by checking this box in the default MATE terminal application.


  • What graphical terminal program are you launching? Whichever one it is, you could try configuring it to launch the Bash shell with --login option which causes Bash to read your ~/.bash_profile, ~/.bash_login, and ~/.profile files (in that order).
    – celadon
    Mar 5, 2020 at 17:31
  • MATE terminal. Thank you. I will look for that option.
    – Kalanos
    Mar 5, 2020 at 17:35
  • Please edit your question and tell us what sort of things you have added to ~/.bash_profile and when you need them to be sourced. The simple answer is that you probably want to be using ~/.bashrc instead of ~/.bash_profile, but the details will depend on exactly what you are doing.
    – terdon
    Mar 5, 2020 at 17:42
  • @celadon not quite. When launched as a login shell, bash will read /etc/profile and then it will only read the first of those files. So if ~/.bash_profile exists, ~/.bash_login and ~/.profile will be ignored. From the INVOCATION section of man bash: "After reading [/etc/profile], it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable."
    – terdon
    Mar 5, 2020 at 17:45
  • 1
    @HashRocketSyntax my answer here might be helpful: Scripts in /etc/profile.d Being Ignored?
    – terdon
    Mar 5, 2020 at 17:46

2 Answers 2


Don't use profile for this. Instead, add your changes to ~/.bashrc. That's the file most commonly used for this sort of thing which you want evaluated for each shell you open.

So, just remove your modifications from ~/.profile and add them to ~/.bashrc instead. For more details on which files are read under what circumstances, see this answer on our sister site, Ask Ubuntu:


  • So, I thought the whole point of creating a .bash_profile was so that you don't mess with the defaults in .bashrc. Is that not the case?
    – Kalanos
    Mar 5, 2020 at 18:03
  • That being said. I have done this and it is working.
    – Kalanos
    Mar 5, 2020 at 18:04
  • 1
    @HashRocketSyntax no, not at all. ~/.bash_profile (and ~/.profile) and ~/.bashrc are all there for each user to play with. You are supposed to mess with them, the ones you shouldn't mess with unless you know what you're doing are /etc/bash.bashrc (sometimes also called /etc/bashrc) and /etc/profile. Anything in your ~/ is there for you to edit. It's just that the normal file to edit for this sort of thing is ~/.bashrc and not ~/.bash_profile.
    – terdon
    Mar 5, 2020 at 19:05
  • Exactly and don't forget to check for an interactive session!
    – WGRM
    Mar 6, 2020 at 17:15

This depends on your graphical environment (LXDM, XFCE, KDE, etc). Some of them don't source ~/.bash_profile.

If you have your reason to use it (e.g. compatibility reasons), you can source it in your ~/.bashrc (expecting you are using bash as your default shell).

echo "source ~/.bash_profile" >> ~/.bashrc

This method comes with some disadvantages.

  • It will only be sourced by interactive login shells.
  • Other graphical programs won't have the same environment.

I would recommend to use something which works natively with your setup.

  1. Use /etc/profile
    • It's global.
    • Affects all user.
    • Disadvantage: It can be overriden more easily because it is sourced very early (but never experienced this in reality. But some desktop environments or something similar set their own unique environment and override the old).
  2. Checkout the behaviour of your desktop environment. LXDM for example will source the following (and not ~/.bash_profile):




In response to your edit: As expected, mate doesn't source ~/bash_profile by default.

Some stuff about design decisions (because you asked it in you latest comment). Typically you only set environment variables in your ~/.bash_profile, /etc/profile etc why I would consider to move your script else where and not in the ~/.bashrc.

What you are doing is very shell specific. It's reasonable to put it in your ~/.bashrc.

If you are using more shells than one, you could split it into different files. For example define your VIRTUAL_ENV_DISABLE_PROMPT inside a environment file like /etc/profile, create a new bash script with the function virtualenv_info() and only source the script in the shell environment where you need it. This would be a clean solution but it will work if you only put the whole script into your ~/.bashrc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.