When you log in to a UNIX system, the login program usually starts a shell for you. The login program setsto tell a shell that it's a login shell.
If the shell doesn't have that flag set, it won't act like a login shell. Opening a new window in a window system may or may not start a login shell - that depends on the configuration. (For example, the command xterm -ls starts a login shell in an; xterm +ls starts a non-login shell.) When you connect to a system with programs like ftp and uucp, that usually starts a non-login shell. And a is never a login shell.
How can you tell whether your shell is a login shell? Unfortunately for newcomers, the answer is: "it depends." The scheme does make sense - after you get familiar with it, anyway. When you first log in to a system, you want a login shell that sets things like the Other shells on the same terminal should be non-login shells - to avoid redoing those one-time-only setup commands. Different shells have their own methods for handling first-time shell invocations vs. later invocations, and that's what the rest of this article is about..
Finally, at the risk of really getting ahead of myself: in all the shells I know of, don't read any setup file. Instead, they start another instance of your current shell. Parentheses are called "subshell operators," but the subshell they start doesn't print a prompt and usually has a short lifetime.
Whew. Read on (I recommend that you read about all of the shells). Then experiment with your shell's setup files until you get things working the way you want them.
The Bourne shell doesn't read .profile when you start a, though. Subshell setup information has to come from that were set in .profile when you first logged in or from commands you typed since.
The .cshrc file is read any time a C shell starts - that includes shell escapes and shell scripts.  This is the place to put commands that should run every time you start a shell. For instance, shell variables likeand should be set here. should, too. Those things aren't passed to subshells through the environment, so they belong in .cshrc.
 If you write a csh script, you should probably use the -f option to keep C shell scripts from reading .cshrc. Of course, even better, you probably.
Commands you want to run every time you log in - checking for, running , checking your calendar for the day, etc.
Note that .cshrc is read before .login.
The shell reads .logout when you end a login shell. Article 2.7 has tips for reading .logout from non-login shells.
The Korn shell is a lot like the Bourne shell.
will read the .profile first.
The .profile can set the
environment variable to the pathname of a file
any Korn shell during that login session (including a subshell)
will read the file named by
$ENV as it starts up, before it runs
bash is something of a cross between the Bourne and C shells. A login bash will read .bash_profile, .bash_login, or .profile. A bash subshell - but not a login shell - will read a file named .bashrc in your home directory. The shell reads .bash_logout when you end a login shell; you can set a to handle non-login shells.