Environment Variables Assignment Help

Assignment Help: >> Shell Programming - Environment Variables

Environment Variables

Environment variables are a predefined variable where the user can store values and make it as the current environment settings.

$MAIL

Whenever used interactively the shell looks at the file specified through this variable before it issues a prompt. The shell prints the message you have mail before prompting for the next command if the specified file has been changed because it was last opened. This variable is classically set in the file .profile in the user's login directory.

MAIL=/usr/mail/fred

$HOME

This is the default argument for the cd command. A current directory is used to resolve file name references which do not starts with a /, and is modigied using the cd command.

The subsequent command

#cd /usr/fred/bin change the   current directory to /usr/fred/bin.

A command cd with no argument is equivalent to

#cd $HOME

This variable also set within the user's login profile.

$PATH

It Stores the list of directories which hold commands (the search path). Every time a command is executed through the shell, a list of directories is fined for an executable file. If $PATH is not set then the current directory, /bin, and /usr/bin are searched through default. Otherwise $PATH consists of the directory names separated through :(semicolon).

The following command

PATH=:/usr/fred/bin:/bin:/usr/bin

specifies in which the directories, the current directory (the null string before the first :), /usr/fred/bin, /bin and /usr/bin are to be fined in that order. This enables individual users to have their own 'private' commands which are accessible independent of the current directory. This directory search is not used if the command name contains a /; a single attempt is made to execute the command.

$PS1

It Stores the main shell prompt string, by default, '$ '. The user can modify his prompt. For instance, let consider the following

# PS1=radiant

Now the prompt will be radiant

$PS2

Stores the shell prompt string, by default, '> '

Example

#PS2=radiant

now the prompt will be radiant>

$TERM

It Stores the terminal specification. Unix OS can have various types of terminals like vt100,vt220 and so on

$LOGNAME

This variable holds the user's login name.

# echo $LOGNAME

root

$SHELL

It Stores the name of the shell.

# echo $SHELL

/bin/sh

Note : Using env command, all the environment variables can be viewed.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd