As we saw earlier, your home directory may have a hidden file called .profile. If it doesn't, there'll probably be one or more files named .login, .cshrc, .tshrc, .bashrc, .bash_profile, or .bash_login. These file are shell setup files, the key to customizing your account. Shell setup files contain commands that are automatically executed when a new shell starts - especially when you log in.
Let's take a look at these files. Go to your home directory, then use cat to display the file. Your .profile might look something like this:
PATH=/bin:/usr/bin:/usr/local/bin: export PATH /usr/games/fortune date umask 002 stty erase ^H intr ^C
A .login file might look something like this:
set path = (/bin /usr/bin /usr/local/bin .) /usr/games date umask 002 stty erase ^H intr ^C
As you can see, these sample setup files contain commands to print a "fortune" and the date - just what happened earlier when we logged in! (/usr/games/fortune is a useless but entertaining program that prints a randomly selected saying from its collection. fortune isn't available on all systems.)
But what are these other commands?
The line with PATH=
or set path =
tells the shell
which directories to search for UNIX commands.
This saves you the trouble of typing the complete pathname for each program
you run.
(Notice that /usr/games isn't part of the path, so we had to use
the absolute pathname to get our daily dose of wisdom
from the fortune command.)
The umask command sets the default file permissions
assigned to all files you create.
Briefly, a value of 022 sets the permissions rw-r--r--
(read-write by owner, but read-only by everyone else),
and 002 will produce rw-rw-r--
(read-write by owner and group, but read-only by everyone else).
If this file is a program or a directory, both umasks will also give
execute (x
) permission to all users.
See one of the books in Appendix A or your UNIX documentation for details.
The stty command sets your terminal control characters - for example, the erase and interrupt characters we discussed earlier.
You can execute any of these commands from the command line, as well. For example, to change your erase character from [BACKSPACE] [(CTRL-H)] to [DEL] [CTRL-?] you would enter:
%stty erase ^?
(The [DEL] key actually generates the control code [CTRL-?] so that's what you'll see on your screen.)
Now pressing [DEL] will backspace and erase characters you type. (If your account is already set up to use [DEL] as the erase character, reverse this example, and change the erase character to [BACKSPACE].
If you experiment with stty, be careful not to reset the erase or interrupt character to a character you'll need otherwise. If you do, though, simply log out and then log back in; you'll get the default erase and interrupt characters again.
UNIX has many other configuration commands to learn about; the references in Appendix A list some of them. One popular configuration is to change your screen colors. On some Linux systems (and others), for example, the command setterm -background blue makes a blue background. Unfortunately, different systems do this in different ways; ask a local expert or someone who has a colored screen.
Just as you can execute the setup commands from the command line, the converse is true: any command that you can execute from the command line can be executed automatically when you log in by placing it in your setup file. (Running interactive commands like mail from your setup file isn't a good idea, though.)
You probably shouldn't edit your setup files yet, but it's good to know what's in them. Later, when you know more about UNIX, feel free to add or change commands in this file.