The purpose of this lesson is to give you an overview of what customization is and how you would go about customizing some settings of your Unix account or applications.
While you may have enjoyed using Unix in your account, perhaps there are some things that you would like to make easier, like making an email mailing list or making some shortcuts for commands to cut down on the typing you have to do.
Customizing Your Account
First, realize that, like many things in Unix, there are hundreds and hundreds of customizations you could possibly make.
In order to make a customization, you need to first know exactly what you can change.
Files for customization usually start with a "." (period). These files are sometimes called "dot files." These files are checked when you log in to your account or start up a session at the Unix shell.
You can find what dot files you have in your home directory by this list command:
$ ls -a . .cshrc .history .plan cmc-html store .. .forward .pinerc bin public_html $
Check out this list of possible configuration files (in Appendix I, about halfway down the page).
The dot files you need to change depend on which shell you are using and which application programs you are using.
You can find out what shell you are using like this:
$ echo $SHELL /bin/csh $
Kinds of customizations in dot files
When you customize your account in a dot file, you usually are altering or setting the value of some variable. These variables might be:
- Environment variables that exist system-wide and are used by
Unix to function for you.
Use the Unix env command to look at these.
You can use the Unix setenv command to set the values of these right at the shell prompt, or you can use the setenv command within the proper dot file to set these environment variables.
Check out this list of environment variables (in Appendix II, about two-thirds down the page).
- Variables you create, also called "aliases." These aliases are a way that you can create shortcut names for commands or other things that you might want to use on a command line.
Whenever you do any kind of customization of dot files in your account, be sure to create a backup file.
Making mail aliases
The Unix mail command uses the .mailrc file to customize how it works. One of the most popular things you would want to do is to create mailing lists using the alias. Add lines like these to create a quick way to write to a one or many people using aliases.
Here are example lines that you could add to your .mailrc file to create aliases (NOTE that these lines are entered into the .mailrc file using an editor; these lines are NOT typed at the Unix prompt):
# personal aliases alias john email@example.com alias friends firstname.lastname@example.org email@example.com
When you want to write to everyone listed after the alias friends, just start a mail session like this:
$ mail friends
You may have a Unix account that you do not use for email. But what if someone sends you email at that account? You can customize the .forward file to contain an email address that all email sent to that account is sent. In the .forward file, all you have to put is the email address where all mail should be forwarded.
For example, let's say you have a Unix account at firstname.lastname@example.org, but you want all mail sent to email@example.com sent instead to firstname.lastname@example.org. You need to login to your email@example.com account, and then edit (or create) a .forward file to read: (NOTE that this line is entered into the .forward file using an editor; this line is NOT typed at the Unix prompt):
Make sure that the .forward file is executable by using the chmod command:
$ chmod 755 .forward
Test out this forwarding yourself to make sure it works properly.
Making command aliases
You might find that you type the same command over and over. If it is a short command, no problem; but perhaps you might want to create a short name, or alias, to stand for a longer command.
If you are using the C shell, you can edit your .cshrc file to make aliases for commands.
For example, you could enter these lines in your .cshrc file (NOTE that these lines are entered into the .cshrc file using an editor; these lines are NOT typed at the Unix prompt):
alias ll 'ls -l' alias go '(date; ls -lst; uname)'
If you are using a different shell, the syntax is a bit different. Check with the reference information.
Then, you need to have the shell re-initialized so that the alias can be recognized. You could logout and then log back in.
Or you could try this:
$ source .cshrc $
Once you have the shell re-initialized, you can use the alias:
$ ll total 5 -rw-r--r-- 1 december december 21 Dec 19 21:19 apple.txt -rw-r--r-- 1 december december 21 Dec 19 21:59 applebad.txt -rw-r--r-- 1 december december 23 Dec 19 21:41 applegood.txt -rw-r--r-- 1 december december 21 Dec 19 21:38 bag.txt -rw-r--r-- 1 december december 91 Dec 19 21:19 basket.txt $ go Tue Dec 19 21:16:03 CST 2000 total 5 1 -rw-r--r-- 1 december december 21 Dec 19 21:59 applebad.txt 1 -rw-r--r-- 1 december december 23 Dec 19 21:41 applegood.txt 1 -rw-r--r-- 1 december december 21 Dec 19 21:38 bag.txt 1 -rw-r--r-- 1 december december 91 Dec 19 21:19 basket.txt 1 -rw-r--r-- 1 december december 21 Dec 19 21:19 apple.txt Linux $
You can look at this demonstration of creating an alias command in the bash shell.
Some tips to keep in mind:
- Remember to make a backup of dot files that you change.
- Since customizations have to do with initialization files, log out and log back in for aliases or other kinds of customizations to take effect.
- Don't use names for command aliases that
are the same as Unix command names. This would
cause the Unix name to be "hidden" when you are
working, with unpredictable results.
As an extreme example to illustrate
this point, don't put a line like this in your .cshrc file
(NOTE that these lines are entered into the .cshrc file
using an editor; these lines are NOT typed at the Unix prompt):
alias date rm *
If you do this, perhaps when you login the next time, you might try to find out the current date and time and instead delete all your files:
$ date $ ls $
- Don't forget to use the Unix source command on your dot file, or log out and log back in for a change in the dot file to take effect.
Exercise: Do some of your own customizations
Make a list of what you like and don't like about how your Unix account is set up. For example, what mail aliases would you like? What command aliases? Pick out one thing in this list and make a change in your files to change it.