Environment and Path Setting in Linux – Bash shell is used for various purposes under Linux. How do you customize the shell environment variable under Linux operating systems?
You can use shell variables to store data, set configuration options, and customize the shell environment under Linux. The default shell is Bash under Linux and can be used for the following purposes:
- Configure the look and feel of the shell.
- Set up terminal settings depending on which terminal you’re using.
- Set the search path such as JAVA_HOME, and ORACLE HOME.
- Set environment variables as needed by programs.
- Run commands you want to run whenever you log in or out.
- Set up aliases and/or shell functions to automate tasks to save typing and time.
- Changing bash prompt.
- Setting shell options.
You can use the following commands to view and configure the environment.
Display Current Environment in Linux
To display the current environment, type the following command:
$ set
BASH =/bin/bash
BASH_ARGC = ()
BASH_ARGV = ()
BASH_LINENO = ()
Note – There are other values available in the environment depending on your system. we are not displaying the whole values here.
The $PATH defines the search path for commands. It is a colon-separated list of directories in which the shell looks for commands. The $PS1 defines your prompt settings. see the list of all commonly used shell variables for more information. you can display the value of a variable using the printf or echo command.
$ echo “$HOME”
OR
$ printf”%s\n” $HOME
Sample output
/home/ram
You can modify each environmental or system variable using the export command. Set the PATH environment variable to include the directory where you installed the bin directory with Perl and shell scripts:
export PATH = $ { PATH)/home/ram/bin
OR
export PATH=${PATH}:${HOME}/bin
Pathnames
Every file has a pathname, which is a trail from a directory through part of the directory hierarchy to an ordinary file or a directory. Within a pathname, a slash (/) to the right of a filename indicates that the file is a directory file. The file following the slash can be an ordinary file or a directory file. The simplest pathname is a simple filename, which points to a file in the working directory.
Absolute Pathnames
An absolute pathname starts with a slash (/), which represents the root directory. The slash is followed by the file’s name located in the root directory.

An absolute pathname continues, tracing a path through all intermediate directories, to the file identified by the pathname. String all the filenames in the path together, following each directory with a slash (/). This string of filenames is called an absolute pathname because it locates a file absolutely by tracing a path from the root directory to the file.
The part of a pathname following the final slash is called a simple filename, or basename. the above figure shows the absolute pathnames of directories and ordinary files in part of a filesystem hierarchy.

Relative Pathnames
A relative pathname traces a path from the working directory to a file. The pathname is relative to the working directory. Any pathname that does not begin with the root directory (represented by /) or a tilde (~) is a relative pathname. Like absolute pathnames, relative pathnames can trace a path through many directories. The simplest relative pathname is a simple filename, which identifies a file in the working directory.