you are a new oracle dba and your oracle databases are on unix servers. whenever you login into the server as the oracle user , in the $HOME directory when you type the command ls -la you will see a file called .profile and you wonder what the file is and how you can use it. Also when you type env on your command line you will see some information appearing on your screen and you wonder about what this information is used for and how one would need to set it up.
Below article gives an overview of what the .profile and .env files are and how you can modify them.
Customizing UNIX: environment variables, aliases, and the .profile and .env files |
||||||
The Profile file in your home directory is a collection of Korn shell commands that are executed whenever you login. Commonly, the Profile file is used to set environment variables and shell options. You can also put command aliases in your Profile file, but it’s better to put them in a separate file — commonly called .env (which is pronounced: dot-e-n-v)– that you define and execute in your Profile (which is pronounced: dot-profile).
This document briefly introduces environment variables, shell options, and aliases, and gives sample Profile and .env files.
|
||||||
Aliases | ||||||
Aliases are used to rename commands, and sometimes to include options. You can put aliases in your Profile file, but if you do, they will not be “exported” to subshells. So it’s better to put them in a separate file in your home directory, commonly called .env, and execute the .env file from your Profile:
ENV=~/.env The basic form of an alias is: alias mycommand=UNIXcommand with no space before or after the equal sign. For example: alias search=grep allows you to use the more mnemonic name search for the existing UNIX command grep. A useful alias that includes an option is: alias rm=”rm -i” which executes rm -i files each time you enter rm files thereby saving you from accidentally deleting your files or directories. Another alias: alias print=”lpr -P” might make it easier for you to remember how to print files on UNIX. |
||||||
Options | ||||||
Options change the shell’s behavior by turning controls on or off as in:
Note that the plus and minus are the opposite of the usual: plus for on and minus for off. options can be one option name or a list of option names separated by blanks. For example: set -o vi turns on editing of the command line in the shell. |
||||||
Variables | ||||||
Variables change the shell’s behavior, or that of other programs, by providing a value (instead of an on/off condition) in the form:
variable=value and then you export the variable: export variable For instance: PS1=’\$PWD)–> ‘ sets the first prompt string (PS1) to tell you the current directory and changes the prompt from $ to: the name of the current directory ($PWD) followed by --> Another useful variable is PRINTER, which selects a default print destination. PRINTER=grc105 |
||||||
Using .profile and .env files | ||||||
Now that you have some suggestions of what to put in your Profile and .env files, here’s how to use them.
In the Korn shell, your Profile is executed each time you login. When you make a change in it like this, you might want to execute it yourself, to make the changes for your current login session. So to set the alias for your current login, enter: . Profile Note the “period space” at the beginning of this command, and in the last of the three lines you added to your Profile file in Step 2. Yes, it is necessary. The “dot command” tells the shell to run the command as if you has entered the commands yourself at the command prompt. Without it, the command is run in a subshell, and the changes will disappear when the subshell closes. Want to check whether the alias “took”? In Korn shell, the command: whence cmdname returns the pathname when cmdname is the name of a script or executable program, or the command executed when it’s an alias. |