Basically the environment provides a medium through which the shell process can get or set settings and, in turn, pass these on to its child processes.The environment is implemented as strings that represent key-value pairs.If multiple values are passed, they are typically separated by colon (:) characters.

updating environment strings-56updating environment strings-55

They can be one of two types, environmental variables or shell variables.

Environmental variables are variables that are defined for the current shell and are inherited by any child shells or processes.

Environmental variables are used to pass information into processes that are spawned from the shell.

In this guide, we will discuss how to interact with the environment and read or set environmental and shell variables interactively and through configuration files.

We will be using an Ubuntu 12.04 VPS as an example, but these details should be relevant on any Linux system.

Every time a shell session spawns, a process takes place to gather and compile information that should be available to the shell process and its child processes.It obtains the data for these settings from a variety of different files and settings on the system.When interacting with your server through a shell session, there are many pieces of information that your shell compiles to determine its behavior and access to resources.Some of these settings are contained within configuration settings and others are determined by user input.One way that the shell keeps track of all of these settings and details is through an area it maintains called the environment.The environment is an area that the shell builds every time that it starts a session that contains variables that define system properties.