Unix - Environment: (Amrood) $TEST "Unix Programming" (Amrood) $echo $TEST Unix Programming
Unix - Environment: (Amrood) $TEST "Unix Programming" (Amrood) $echo $TEST Unix Programming
Unix - Environment
Copyright tutorialspoint.com
Unix - Environment
Advertisements
An important Unix concept is the environment, which is defined by environment variables. Some are set by the system, others by you, yet others by the shell, or any program that loads another program. Avariable is a character string to which we assign a value. The value assigned could be a number, text, filename, device, or any other type of data. For example, first we set a variables TEST and then we access its value using echo command:
$
This is the prompt where you can enter commands in order to have them execute. Note - The shell initialization process detailed here applies to all Bourne type shells, but some additional files are used by bash and ksh.
7/10/12
Unix - Environment
contains shell initialization information required by all users on a system. The file .profile is under your control. You can add as much shell customization information as you want to this file. The minimum set of information that you need to configure includes The type of terminal you are using A list of directories in which to locate commands A list of variables effecting look and feel of your terminal. You can check your .profile available in your home directory. Open it using vi editor and check all the variables set for your environment.
7/10/12
Unix - Environment
=P1"\@h\]$ >S=[u\ w\" [oti-217121 /a/w/uoilpitui] ro@p7-6-1-7 vrwwttrason/nx$ [oti-217121 /a/w/uoilpitui] ro@p7-6-1-7 vrwwttrason/nx$
The result of this command is that the prompt displays the user's username, the machine's name (hostname), and the working directory. There are quite a few escape sequences that can be used as value arguments for PS1; try to limit yourself to the most critical so that the prompt does not overwhelm you with information. Escape Sequence \t \d \n \s \W \w \u \h \# \$ Description Current time, expressed as HH:MM:SS. Current date, expressed as Weekday Month Date Newline. Current shell environment. Working directory. Full path of the working directory. Current user.s username. Hostname of the current machine. Command number of the current command. Increases with each new command entered. If the effective UID is 0 (that is, if you are logged in as root), end the prompt with the # character; otherwise, use the $.
You can make the change yourself every time you log in, or you can have the change made automatically in PS1 by adding it to your .profile file. When you issue a command that is incomplete, the shell will display a secondary prompt and wait for you to complete the command and hit Enter again. The default secondary prompt is > (the greater than sign), but can be changed by re-defining the PS2 shell variable: Following is the example which uses the default secondary prompt:
7/10/12
Unix - Environment
$
Following is the example which re-define PS2 with a customized prompt:
Environment Variables:
Following is the partial list of important environment variables. These variables would be set and accessed as mentioned above: Variable DISPLAY HOME IFS Description Contains the identifier for the display that X11 programs should use by default. Indicates the home directory of the current user: the default argument for the cd built-in command. Indicates the Internal Field Separator that is used by the parser for word splitting after expansion. LANG expands to the default system locale; LC_ALL can be used to override this. For example, if its value is pt_BR, then the language is set to (Brazilian) Portuguese and the locale to Brazil. On many Unix systems with a dynamic linker, contains a colonseparated list of directories that the dynamic linker should search for shared objects when building a process image after exec, before searching in any other directories. Indicates search path for commands. It is a colon-separated list of directories in which the shell looks for commands. Indicates the current working directory as set by the cd command. Generates a random integer between 0 and 32,767 each time it is referenced. Increments by one each time an instance of bash is started. This variable is useful for determining whether the built-in exit command ends the current session. Refers to the display type Refers to Time zone. It can take values like GMT, AST, etc. Expands to the numeric user ID of the current user, initialized at shell startup.
LANG
LD_LIBRARY_PATH
www.tutorialspoint.com/cgi-bin/printversion.cgi?tutorial=unix&file=unix-environment.htm
4/5
7/10/12
Unix - Environment
[mod$eh $OE aro] co HM /ot ro [mod$eh $IPA aro] co DSLY [mod$eh $EM aro] co TR xem tr [mod$eh $AH aro] co PT /s/oa/i:bn/s/i:hm/modbn/s/oa/i urlclbn/i:urbn/oearo/i:urlclbn [mod$ aro]
Copyright tutorialspoint.com
www.tutorialspoint.com/cgi-bin/printversion.cgi?tutorial=unix&file=unix-environment.htm
5/5