Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am a newbie to UNIX. I am using mac OS X 10.8. I created .profile under home directory. However, it does not work when login. I always have to force it to work using the command $ . ~/.profile. Can anyone explain it for me?

Another question, I try to write a Cshell name wld and make it executable. However, I cannot call it just by typing $ wld. I have to type $./wld. How to make it work normally?

share|improve this question

migrated from Jan 8 '13 at 22:04

This question came from our site for professional and enthusiast programmers.

up vote 2 down vote accepted

~/.profile is not read by bash, if ~/.bash_profile or ~/.bash_login exists. Also remember that ~/.profile is executed by the command interpreter for login shells and ~/.bashrc is executed for non-login shells. You can read more here:

Scripts are usually placed in ~/.bashrc and there is this code in ~/.profile:

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
    . "$HOME/.bashrc"
share|improve this answer
Do note that OS X by default runs a login shell for a new Terminal window. – slhck Jan 8 '13 at 22:33
@Nykakin: thanks I've tried to use ~/.bash_profile. It works. I also want to practice Cshell as I wrote in the second question, how can I run executable file wld just by typing $ wld instead of $ ./wld – HuongOrchid Jan 9 '13 at 16:05
See here: – Nykakin Jan 9 '13 at 16:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .