0% found this document useful (0 votes)
46 views

The .Profile File: "Unix Programming"

This document discusses the Unix environment and environment variables. It explains that environment variables can be set by the system, shell, or programs to define the environment. It provides an example of setting the TEST variable and accessing its value. The document also describes how the shell initializes by reading the /etc/profile and ~/.profile files upon login, then displays a prompt for commands. It outlines the purpose of these files and some common variables that should be set in ~/.profile, such as the terminal type.

Uploaded by

rahul
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views

The .Profile File: "Unix Programming"

This document discusses the Unix environment and environment variables. It explains that environment variables can be set by the system, shell, or programs to define the environment. It provides an example of setting the TEST variable and accessing its value. The document also describes how the shell initializes by reading the /etc/profile and ~/.profile files upon login, then displays a prompt for commands. It outlines the purpose of these files and some common variables that should be set in ~/.profile, such as the terminal type.

Uploaded by

rahul
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

In this chapter, we will discuss in detail about the Unix environment.

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.
A variable 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 variable TEST and then we access its value using
the echo command −
$TEST="Unix Programming"
$echo $TEST

It produces the following result.


Unix Programming
Note that the environment variables are set without using the $ sign but while
accessing 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 system, the shell undergoes a phase called initialization to
set up the environment. This is usually a two-step process that involves the shell
reading the following files −

 /etc/profile
 profile
The process is as follows −
 The shell checks to see whether the file /etc/profile exists.
 If it exists, the shell reads it. Otherwise, this file is skipped. No error message
is displayed.
 The shell checks to see whether the file .profile exists in your home
directory. Your home directory is the directory that you start out in after you
log in.
 If it exists, the shell reads it; otherwise, the shell skips it. No error message is
displayed.
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 executed.
Note − The shell initialization process detailed here applies to all Bourne type
shells, but some additional files are used by bash and ksh.

The .profile File


The file /etc/profile is maintained by the system administrator of your Unix machine
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 −

 The type of terminal you are using.


 A list of directories in which to locate the commands.
 A list of variables affecting the look and feel of your terminal.
You can check your .profile available in your home directory. Open it using the vi
editor and check all the variables set for your environment.

Setting the Terminal Type


Usually, the type of terminal you are using is automatically configured by either
the login or getty programs. Sometimes, the auto configuration process guesses
your terminal incorrectly.
If your terminal is set incorrectly, the output of the commands might look strange, or
you might not be able to interact with the shell properly.
To make sure that this is not the case, most users set their terminal to the lowest
common denominator in the following way −
$TERM=vt100
$

You might also like