Databases Reference
In-Depth Information
Customizing Your OS Command Prompt
Typically, DBAs work with multiple servers and multiple databases. In these situations, you may have numerous
terminals' sessions open on your screen. You can run the following types of commands to identify your current
working environment:
$ hostname -a
$ id
$ who am i
$ echo $ORACLE_SID
$ pwd
To avoid confusion about which server you're working on, it's often desirable to configure your command prompt
to display information regarding its environment, such as the machine name and database SID. In this example the
command prompt name is customized to include the hostname, user, and Oracle SID:
$ PS1='[\h:\u:${ORACLE_SID}]$ '
The \h specifies the hostname. The \u specifies the current OS user. $ORACLE_SID contains the current setting for
your Oracle instance identifier. Here is the command prompt for this example:
[oracle12c:oracle:o12c]$
The command prompt contains three pieces of important information about the environment: server name,
OS username, and database name. When you're navigating among multiple environments, setting the command
prompt can be an invaluable tool for keeping track of where you are and what environment you're in.
If you want the OS prompt automatically configured when you log in, then you need to set it in a startup file.
In a Bash shell environment, you typically use the .bashrc file. This file is normally located in your HOME directory.
Place the following line of code in .bashrc :
PS1='[\h:\u:${ORACLE_SID}]$ '
When you place this line of code in the startup file, then any time you log in to the server, your OS prompt is set
automatically for you. In other shells, such as the Korn shell, the .profile file is the startup file.
Depending on your personal preference, you may want to modify the command prompt for your particular
needs. For example, many DBAs like the current working directory displayed in the command prompt. To display the
current working directory information, add the \ w variable:
$ PS1='[\h:\u:\w:${ORACLE_SID}]$ '
As you can imagine, a wide variety of options are available for the information shown in the command prompt.
Here is another popular format:
$ PS1='[\u@${ORACLE_SID}@\h:\W]$ '
Table 3-1 lists many of the Bash shell variables you can use to customize the OS command prompt.
 
Search WWH ::




Custom Search