When you log in, the system first asks for your user name (to identify your home directory and permissions), then your password (to confirm your identity). Having identified your account, the system then starts a shell for you.
If you are using the Bourne shell (sh) or the Korn shell (ksh), the shell first executes the commands stored in the generic environment file /etc/profile, then the commands stored in the personalized environment file called .profile located in your home directory, if that file exists.
A Korn shell additionally looks for a file called .kshrc; but only if ENV is set and exported and if .kshrc exists. The startup file for ksh can be named any valid file name and is not constrained to be .kshrc. .kshrc is not a startup file hardcoded into ksh, but rather a common name that is used for the ksh startup file specified (optionally) by the ENV environment variable in your environment. The .kshrc is executed after .profile.
If you are using the C shell (csh), the shell executes the commands stored in the file /etc/cshrc, then any commands present in a file called .cshrc in your home directory, if that file exists. The shell then looks for a file called .login; if it exists, any commands in it are executed. Note that the default prompt for the Korn and Bourne shells is the ``$''; the C shell's default prompt is ``ServerName%''.
You can find annotated examples of .profile, .kshrc, .login, and .cshrc files in ``Sample shell startup files''.
These files set up your work environment. They contain commands to configure your terminal type and to set up various environment variables (see ``Understanding variables'' for details). The login files also contain any other commands that you want to have executed every time you log in.