You have seen that using the -a option with the ls command will list hidden dot files. Remember that any file that has a name beginning with a . is hidden unless you use the -a option with thels command. Although you can make any file you want hidden by preceeding its name with a dot, your account will have some dot files in it already which are system files. These files specify how your Unix environment should be set up when you log in, or they may specify certain preferences used in various Unix programs.
Let's talk about these dot files and how they can be customized.
Step 1.To return to your home directory, type:
Step 2.To see a long list of your dot files, type:
ls -la Enter
Some of the dot files you see are:
You may see some other dot files as well.
NOTE: You can see a more complete list of dot files by using the question, "In Unix, what are some common dot files?" as your search phrase in the Knowledge Base at:
The.login file has commands that execute automatically every time you log into your Unix account. If you wanted a certain command to execute when you logged in, you could edit your.login file to include that command. For example, if you put the command nanoat the end of your.login file, then Nano would automatically start up when you logged into your Unix account.
We are not going to look at the.login file today, but will concentrate on the.profile file instead.
Customizing Your.profile File With Aliases
The .profile file contains information about how the shell should be set up. The.profile file is where aliases are stored. An alias is a custom name you give to a Unix command. For example, if you prefer to type "list" to get a file listing, rather than ls, you can use "list" as an alias for ls. Or, you may wantls to always give you a long listing, with dot files. In this case, you could set up ls as an alias for ls -la. Let's add this alias to our.profile file.
Step 1.To begin editing your.profile file, type:
As you can see, your.profile file already contains a lot of information. Any line that begins with a # is a comment, which is ignored by Unix when executing the file. Comments often have information from the system administrator about what is in the file, and how to customize it. It is worthwhile to read these comments.
There may already be some aliases set up for you by the system administrator. We will now add our own alias.
Step 2.Use the arrow keys to move to where the aliases are. If there are no aliases, move to the bottom of the document.
Step 3.To add a new ls alias, type:
alias ls="ls -la" Enter
Step 4.To exit Nano, type:
Step 5.To save the changes we have made, type:
Step 6.To accept the filename.profile, press:
We need to direct the host to re-check the.profile file in order for our changes to take effect. Otherwise, they will take effect upon our next login.
Step 7.To have Unix re-check the.profile file, type:
. .profile Enter
Now our changes to our shell have been implemented.
Step 8.To verify that the new alias works, type:
You see a long listing of your files.
Here are some other commonly used aliases:
- rmas alias for rm -i (i will ask you to verify each delete, already exists on mercury accounts)
- edit as alias for Nano (already exists on mercury accounts)
- help as alias for apropos
- lo as alias for exit (exit will log you out of the system, or return you to the main menu)