Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 stackoverflow.com Jan 8 '13 at 22:04

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

add comment

1 Answer

up vote 1 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: http://stefaanlippens.net/bashrc_and_others

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"
    fi
fi
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: washington.edu/computing/unix/searchpath.html –  Nykakin Jan 9 '13 at 16:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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