Do I Have to Type the Same Things Every Time I Log In?
Most users find that, every time they log in, they type the same commands to set up the computer the way they like it. You may typically change to your favorite directory, for example, and then change the terminal settings (see the following section), check your mail, or do any of a dozen other things.The Bourne, Korn, and BASH shells look in your home directory for a file called .profile when you log in. If the .profile file exists, UNIX executes the commands in that file. The C shell has two corresponding files:.login (which it runs when you log in) and .cshrc (which it runs every time you start a new C shell, either at login time or when you type csh).Your system administrator probably gave you a standard .profile or .login file when your account first was set up. Messing with stuff that’s already there is definitely not a good idea. You may end up unable to log in and then have to crawl to your system administrator and beg for help. So don’t say that we didn’t warn you.The standard .profile , .login , and .cshrc files vary considerably (why do we even finish this sentence — you know what we’re going to say) from one system to another, depending on the tastes of the system administrator. These files usually perform this tasks:Set up the search path the shell uses to look for commands
Arrange to notify you when you have new mail
(Sometimes) change the shell prompt from the usual $ or % to something more informative
If you always type the same commands when you log in, adding new commands at the end of .profile or .login is fairly safe. If you do most of your work in the directory bigproject , for example, you may add the following three lines to the end of the file your shell uses to start up your UNIX session (.profile or .cshrc ):
# change to bigproject, added 3/04
cd bigproject
echo Now in directory bigproject.
The first line is a comment the computer ignores but is useful for humans trying to figure out who changed what. Any line that starts with a pound sign (# ) is a comment. The second line is a regular cd command. The third line is an echo command that displays a note on-screen to remind you of the directory you’re in.Tip If you use the C shell, a frequently useful command to put in .login is this one: set ignoreeof
If you press Ctrl+D in the shell, the shell normally assumes that you’re finished for the day and logs you out — in keeping with the traditional UNIX “you asked for it, you got it” philosophy. Many people think that you should be more explicit about your intention to log out and use ignoreeof to tell the shell to ignore Ctrl+D (the following section tells you what eof has to do with Ctrl+D) and log out only when you type exit or logout.