This problem I have for a long time. After running terminal .profile, and .bashrc file doesn`t work (are not executed). Could you indicate where should I looking form a source of problem?

  • check whether this files have a proper permissions
    – shuvalov
    Aug 14, 2010 at 17:48
  • yes... you are right the reason was really stupid - incorrect permissions chmod +x ~/.profile and everything is working well.
    – michaltaberski
    Aug 14, 2010 at 18:27
  • 5
    @xTrol: That doesn't make sense, ~/.profile doesn't require execute permission. (The shell sources it, it doesn't execute it). Try chmod -x ~/.profile and see if it still works. Nov 4, 2011 at 0:15

5 Answers 5


I had a similar problem with my .profile not being run. It turns out (as explained in this Apple StackExchange answer) that if you have .bash_profile or .bash_login files, then your .profile will be ignored by bash.

  • 2
    My issue was I installed Python which automatically created a .bash_profile file which caused my .profile not to run.
    – SharpPer
    Apr 12, 2012 at 17:08
  • 5
    This answer helps me. .bash_login was added after I installed rvm.
    – Neevek
    Aug 10, 2012 at 16:34

I guess this Q&A should go to Superuser, but anyway:

According to the section INVOCATION of the man page,

  • /etc/profile and ~/.profile is read for an interactive login shell, and
  • ~/.bashrc is read for an interactive non-login shell.

If your other UNIX machine automatically read ~/.bashrc even for an interactive login shell, that's because the system-wide /etc/ profile has a line which reads ~/.bashrc. OS X's system-wide /etc/profile doesn't have one.

So, if you want to run ~/.bashrc even for an interactive login shell, you need to include a line

. ~/.bashrc

in your ~/.profile.

  • And to fill in the missing piece here: A Terminal shell (which the OP's question was about) is by default an interactive login shell.
    – LarsH
    Oct 27, 2017 at 13:57

Try sourcing them "by hand":

source ~/.profile

and see what happens. Note that, as others have pointed out, .profile is sourced by login shells, .bashrc by non-login shells; so try one or the other, not both.


In your terminal preferences, check in the 'Startup' pane. You have options:

Shells open with:

  • Default login shell (/usr/bin/login)
  • Command (complete path)

I have 'default' chosen...if you have the custom command chose, that may be a factor.

The next point to check is whether the shell is started as a login shell. When I do a ps listing, I see:

  PID TTY           TIME CMD
24088 ttys000    0:00.03 -sh
24614 ttys001    0:00.03 -sh
25127 ttys002    0:00.05 -sh
35544 ttys003    0:00.08 -sh
40926 ttys004    0:00.03 -sh

The key point here is the '-' in front of the shell name; that tells the shell to run through the profile and related stuff. If you don't see that in your current windows, you may need to diddle with the settings until you do.

The settings pane in the terminal preferences also lists a shell option. I have /bin/sh listed in mine.

You should not need this

If the worst comes to the worst, you can do as I did on some other uncooperative systems in times past - I created a program 'loginsh' which I could run from windows, and it in turn would execute my chosen shell with the '-' prefix to tell it to work as a login shell.

#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include "stderr.h"
#include "jlss.h"

#define DEFAULT_SHELL   "/bin/sh"
#endif /* DEFAULT_SHELL */


#ifndef lint
static const char sccs[] = "@(#)$Id: loginsh.c,v 4.2 2005/06/22 19:44:07 jleffler Exp $";

int main(int argc, char **argv)
    char     *shell;
    char      shellname[MAX_SHELLBASENAME];


    /* Which shell to use? */
    if ((shell = getenv("SHELL")) == (char *)0)
        shell = DEFAULT_SHELL;

    /* Set up argv[0] in new argument list; reuse old argv space */
    shellname[0] = '-';
    strcpy(&shellname[1], jlss_basename(shell));
    argv[0] = shellname;

    /* Execv must work -- the shell must be an executable program */
    execv(shell, &argv[0]);
    err_syserr("cannot execute shell %s\n", shell);

    /* NOTREACHED */

(The "stderr.h" header and 'err_*' routines are an error reporting package I use everywhere. The jlss_basename() function is basically the same as system provided versions such as are found in POSIX <libgen.h>.)


Good information above, but thought I'd share some specifics on the problem I had and the solution I found.

The need: Add a directory to PATH on OSX 10.8 (ML).

The problem: Guidance is often "mod the .profile in your home directory". A bit confusing since, by default, this file doesn't exist on OSX. Doubly confusing because once you add an export statement to append the new directory to the existing PATH ... it doesn't work. Covered above.

The solution: I added the export statement to my .bash_profile (also in the home directory).

I'm sure there are many ways to skin this cat. This one worked for me. Somewhat confidence inspiring: the .bash_profile already existed and I could see that other installed software (e.g. Ruby) had modified it. If there's a better solution I'll be glad to hear about it!

You must log in to answer this question.