UNIX TUTORIALS - Unix - Environment
Unix - Environment
ADVERTISEMENTS
PS1 and PS2 Variables:
Escape Sequence | Description |
---|---|
\t | Current time, expressed as HH:MM:SS. |
\d | Current date, expressed as Weekday Month Date |
\n | Newline. |
\s | Current shell environment. |
\W | Working directory. |
\w | Full path of the working directory. |
\u | Current user.s username. |
\h | 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 $. |
ADVERTISEMENTS
Environment Variables:
Variable | Description |
---|---|
DISPLAY | Contains the identifier for the display that X11 programs should use by default. |
HOME | Indicates the home directory of the current user: the default argument for the cd built-in command. |
IFS | Indicates the Internal Field Separator that is used by the parser for word splitting after expansion. |
LANG | 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. |
LD_LIBRARY_PATH | On many Unix systems with a dynamic linker, contains a colon-separated 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. |
PATH | Indicates search path for commands. It is a colon-separated list of directories in which the shell looks for commands. |
PWD | Indicates the current working directory as set by the cd command. |
RANDOM | Generates a random integer between 0 and 32,767 each time it is referenced. |
SHLVL | 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. |
TERM | Refers to the display type |
TZ | Refers to Time zone. It can take values like GMT, AST, etc. |
UID | Expands to the numeric user ID of the current user, initialized at shell startup. |
ADVERTISEMENTS
$TEST="Unix Programming" $echo $TEST Unix Programming
$Setting the Terminal Type:
$TERM=vt100 $Setting the PATH:
$PATH=/bin:/usr/bin $
$hello hello: not found $PS1 and PS2 Variables:
$PS1='=>' => => =>
=>PS1="[\u@\h \w]\$" [root@ip-72-167-112-17 /var/www//unix]$ [root@ip-72-167-112-17 /var/www//unix]$
$ echo "this is a > test" this is a test $
$ PS2="secondary prompt->" $ echo "this is a secondary prompt->test" this is a test $Environment Variables:
$ echo $HOME /root ]$ echo $DISPLAY $ echo $TERM xterm $ echo $PATH /usr/local/bin:/bin:/usr/bin:/home/amrood/bin:/usr/local/bin $