In this division, we will discuss in detail about the UNIX environment. A main UNIX model 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.
A variable is a character string to which we allocate a value. The value assigned could be a number, text, filename, device, or any other kind of data.
For instance, first we set a variable TEST and then we contact its value using the echo command –
It produces the following result.
Note that the environment variables are set without using the $ sign but while access them we use the $ sign as prefix. These variables retain their values until we come out of the shell.
When you log in to the structure, the shell undergoes a phase called initialization to set up the environment. This is generally a two-step process that involves the shell understanding the following files −
The development is as follows −
As soon as both of these files have been read, the shell displays a prompt –
This is the prompt where you can enter commands in order to have them execute.
Note − the shell initialization process complete here applies to all Bourne type shells, but some extra files are used by bash and kasha.
The file /etc/profile is maintain by the scheme administrator of your UNIX device and 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 −
You can check your .profile accessible in your home directory. Open it using the VI editor and check all the variables set for your environment.
Usually, the kind of terminal you are using is automatically configured by either the login or Getty programs. Sometimes, the auto arrangement process guesses your terminal wrongly.
If your workstation is set wrongly, the output of the commands might look strange, or you might not be able to interact with the shell correctly.
To make sure that this is not the case, most users set their fatal to the lowest common denominator in the following way –
When you form any command on the command prompt, the shell has to locate the command before it can be executed.
The PATH variable specifies the location in which the shell should look for commands. Usually the Path variable is set as follows –
Here, each of the individual entry separated by the colon character (:) are directories. If you request the shell to execute a command and it cannot find it in any of the directories given in the PATH variable, a message parallel to the following appears –
There are variables like PS1 and PS2 which are discuss in the next section.
The characters that the shell displays as your command prompt are stored in the variable PS1. You can modify this variable to be anything you want. As soon as you alter it, it'll be used by the shell from that point on.
For instance, if you issued the command –
Your prompt will become =>. To set the value of PS1 so that it shows the working directory, issue the command –
The result of this command is that the prompt display the user's username, the equipment name (hostname), and the effective directory.
There are fairly a few escape sequences that can be used as value influence for PS1; try to limit yourself to the most critical so that the prompt does not overpower you with information.
|S.No.||Escape Sequence & Description|
You can construct the modify 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 charge that is incomplete, the shell will show a secondary prompt and wait for you to complete the command and hit Enter once more.
The default secondary prompt is > (the greater than sign), but can be transformed by re-defining the PS2 shell variable −
Following is the instance which uses the defaulting secondary prompt –
The instance given below re-defines PS2 with a modified prompt –
Following is the partial list of important environment variables. These variables are located and accessed as mention below −
|S.No.||Variable & Description|
Following is the sample instance presentation few environment variables –
Unix/Linux Related Interview Questions
|Perl Scripting Interview Questions||Shell Scripting Interview Questions|
|Python Interview Questions||Core Java Interview Questions|
|Linux Interview Questions||Linux Embedded systems Interview Questions|
|Red Hat Linux System Administration Interview Questions||IBM AIX Interview Questions|
|Sybase Interview Questions||IBM AIX 7 Administration Interview Questions|
|Unix Shell Scripting Interview Questions||Linux Shell Scripting Interview Questions|
Unix/Linux Related Practice Tests
|Perl Scripting Practice Tests||Shell Scripting Practice Tests|
|Python Practice Tests||Core Java Practice Tests|
|Linux Practice Tests||Linux Embedded systems Practice Tests|
|Red Hat Linux System Administration Practice Tests||IBM AIX Practice Tests|
|Sybase Practice Tests||IBM AIX 7 Administration Practice Tests|
|Autosys Practice Tests|
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.