Skip to main content

Introduction

Environment variables in Unix-like operating systems determine the behavior and access in the system. Some of the settings are contained within configuration settings, other are determined by user input. The shell keeps track of all the settings in the environment, that builds every time it starts a session with variables, defining system properties. Environment variables by convention are defined using capital letters.

The list of environmental variables is show by using commands env and printenv :

$ printenv
XDG_VTNR=7
LC_PAPER=en_GB.UTF-8
LC_ADDRESS=en_GB.UTF-8
XDG_SESSION_ID=c2
XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/aav
LC_MONETARY=en_GB.UTF-8
CLUTTER_IM_MODULE=xim

printenv can request for particular variable

$ printenv SHELL
/bin/bash

env can set variables like:

$ env test_var="The test"
$ echo $TEST_VAR
The test

Shell variables are shown with the set command:

$ set
BASH=/bin/bash
BASHOPTS=checkwinsize:cmdhist
BASH_ALIASES=()
BASH_ARGC=()
BASH_ARGV=()
BASH_CMDS=()

Creating shell variable:

$ SOME_VAR="test shell var"

This variable is defined only for the shell.

$ set | grep SOME_VAR

But not in the environment variables:

$ printenv | grep SOME_VAR 

Creating environment variable Shell variables can be turned into environment variables

$ export SOME_VAR

$ printenv | grep SOME_VAR

Environment variable can be turned back to shell variables

$ export -n SOME_VAR

Common environment variables

PATH – a list of directory paths. When the user types a command without providing the full path, this list is checked to see whether it contains a path that leads to the command.

HOME (Unix-like) - dicate where a user's home directory is located in the file system.

TERM – specifies the type of computer terminal or terminal emulator being used (e.g., vt100).

MAIL – used to indicate where a user's mail is to be found.

SHELL - default shell

PWD - prints current working directory

###Further reading

Is there a “.bashrc” equivalent file read by all shells?Is there a “.bashrc” equivalent file read by all shells?

What is the difference between 'env' and 'printenv'?

How to permanently set environmental variables

What is the difference in usage between shell variables and environment variables?

###External References

How To Read and Set Environmental and Shell Variables on a Linux VPS

env utility specification (The Open Group Base Specifications Issue 7, 2018 edition)

Environment Variables (The Open Group Base Specifications Issue 7, 2018 edition)

Introduction

Environment variables in Unix-like operating systems determine the behavior and access in the system. Some of the settings are contained within configuration settings, other are determined by user input. The shell keeps track of all the settings in the environment, that builds every time it starts a session with variables, defining system properties. Environment variables by convention are defined using capital letters.

The list of environmental variables is show by using commands env and printenv :

$ printenv
XDG_VTNR=7
LC_PAPER=en_GB.UTF-8
LC_ADDRESS=en_GB.UTF-8
XDG_SESSION_ID=c2
XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/aav
LC_MONETARY=en_GB.UTF-8
CLUTTER_IM_MODULE=xim

printenv can request for particular variable

$ printenv SHELL
/bin/bash

env can set variables like:

$ env test_var="The test"
$ echo $TEST_VAR
The test

Shell variables are shown with the set command:

$ set
BASH=/bin/bash
BASHOPTS=checkwinsize:cmdhist
BASH_ALIASES=()
BASH_ARGC=()
BASH_ARGV=()
BASH_CMDS=()

Creating shell variable:

$ SOME_VAR="test shell var"

This variable is defined only for the shell.

$ set | grep SOME_VAR

But not in the environment variables:

$ printenv | grep SOME_VAR 

Creating environment variable Shell variables can be turned into environment variables

$ export SOME_VAR

$ printenv | grep SOME_VAR

Environment variable can be turned back to shell variables

$ export -n SOME_VAR

Common environment variables

PATH – a list of directory paths. When the user types a command without providing the full path, this list is checked to see whether it contains a path that leads to the command.

HOME (Unix-like) - dicate where a user's home directory is located in the file system.

TERM – specifies the type of computer terminal or terminal emulator being used (e.g., vt100).

MAIL – used to indicate where a user's mail is to be found.

SHELL - default shell

PWD - prints current working directory

###Further reading

Is there a “.bashrc” equivalent file read by all shells?

What is the difference between 'env' and 'printenv'?

How to permanently set environmental variables

What is the difference in usage between shell variables and environment variables?

###External References

How To Read and Set Environmental and Shell Variables on a Linux VPS

env utility specification (The Open Group Base Specifications Issue 7, 2018 edition)

Environment Variables (The Open Group Base Specifications Issue 7, 2018 edition)

Introduction

Environment variables in Unix-like operating systems determine the behavior and access in the system. Some of the settings are contained within configuration settings, other are determined by user input. The shell keeps track of all the settings in the environment, that builds every time it starts a session with variables, defining system properties. Environment variables by convention are defined using capital letters.

The list of environmental variables is show by using commands env and printenv :

$ printenv
XDG_VTNR=7
LC_PAPER=en_GB.UTF-8
LC_ADDRESS=en_GB.UTF-8
XDG_SESSION_ID=c2
XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/aav
LC_MONETARY=en_GB.UTF-8
CLUTTER_IM_MODULE=xim

printenv can request for particular variable

$ printenv SHELL
/bin/bash

env can set variables like:

$ env test_var="The test"
$ echo $TEST_VAR
The test

Shell variables are shown with the set command:

$ set
BASH=/bin/bash
BASHOPTS=checkwinsize:cmdhist
BASH_ALIASES=()
BASH_ARGC=()
BASH_ARGV=()
BASH_CMDS=()

Creating shell variable:

$ SOME_VAR="test shell var"

This variable is defined only for the shell.

$ set | grep SOME_VAR

But not in the environment variables:

$ printenv | grep SOME_VAR 

Creating environment variable Shell variables can be turned into environment variables

$ export SOME_VAR

$ printenv | grep SOME_VAR

Environment variable can be turned back to shell variables

$ export -n SOME_VAR

Common environment variables

PATH – a list of directory paths. When the user types a command without providing the full path, this list is checked to see whether it contains a path that leads to the command.

HOME (Unix-like) - dicate where a user's home directory is located in the file system.

TERM – specifies the type of computer terminal or terminal emulator being used (e.g., vt100).

MAIL – used to indicate where a user's mail is to be found.

SHELL - default shell

PWD - prints current working directory

###Further reading

Is there a “.bashrc” equivalent file read by all shells?

What is the difference between 'env' and 'printenv'?

How to permanently set environmental variables

What is the difference in usage between shell variables and environment variables?

###External References

How To Read and Set Environmental and Shell Variables on a Linux VPS

env utility specification (The Open Group Base Specifications Issue 7, 2018 edition)

Environment Variables (The Open Group Base Specifications Issue 7, 2018 edition)

Updated usage guidence. Updated external reference.
Source Link

Introduction

Environment variables in Unix-like operating systems determine the behavior and access in the system. Some of the settings are contained within configuration settings, other are determined by user input. The shell keeps track of all the settings in the environment, that builds every time it starts a session with variables, defining system properties. Environment variables by convention are defined using capital letters.

The list of environmental variables is show by using commands env and printenv :

$ printenv
XDG_VTNR=7
LC_PAPER=en_GB.UTF-8
LC_ADDRESS=en_GB.UTF-8
XDG_SESSION_ID=c2
XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/aav
LC_MONETARY=en_GB.UTF-8
CLUTTER_IM_MODULE=xim

printenv can request for particular variable

$ printenv SHELL
/bin/bash

env can set variables like:

$ env test_var="The test"
$ echo $TEST_VAR
The test

Shell variables are shown with the set command:

$ set
BASH=/bin/bash
BASHOPTS=checkwinsize:cmdhist
BASH_ALIASES=()
BASH_ARGC=()
BASH_ARGV=()
BASH_CMDS=()

Creating shell variable:

$ SOME_VAR="test shell var"

This variable is defined only for the shell.

$ set | grep SOME_VAR

But not in the environment variables:

$ printenv | grep SOME_VAR 

Creating environment variable Shell variables can be turned into environment variables

$ export SOME_VAR

$ printenv | grep SOME_VAR

Environment variable can be turned back to shell variables

$ export -n SOME_VAR

Common environment variables

PATH – a list of directory paths. When the user types a command without providing the full path, this list is checked to see whether it contains a path that leads to the command.

HOME (Unix-like) - dicate where a user's home directory is located in the file system.

TERM – specifies the type of computer terminal or terminal emulator being used (e.g., vt100).

MAIL – used to indicate where a user's mail is to be found.

SHELL - default shell

PWD - prints current working directory

Reference and further reading ###Further reading

Is there a “.bashrc” equivalent file read by all shells?

What is the difference between 'env' and 'printenv'?

How to permanently set environmental variables

What is the difference in usage between shell variables and environment variables?

###External References

How To Read and Set Environmental and Shell Variables on a Linux VPS

env utility specification (The Open Group Base Specifications Issue 7, 2018 edition)

Environment Variables (The Open Group Base Specifications Issue 7, 2018 edition)

Introduction

Environment variables in Unix-like operating systems determine the behavior and access in the system. Some of the settings are contained within configuration settings, other are determined by user input. The shell keeps track of all the settings in the environment, that builds every time it starts a session with variables, defining system properties. Environment variables by convention are defined using capital letters.

The list of environmental variables is show by using commands env and printenv :

$ printenv
XDG_VTNR=7
LC_PAPER=en_GB.UTF-8
LC_ADDRESS=en_GB.UTF-8
XDG_SESSION_ID=c2
XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/aav
LC_MONETARY=en_GB.UTF-8
CLUTTER_IM_MODULE=xim

printenv can request for particular variable

$ printenv SHELL
/bin/bash

env can set variables like:

$ env test_var="The test"
$ echo $TEST_VAR
The test

Shell variables are shown with the set command:

$ set
BASH=/bin/bash
BASHOPTS=checkwinsize:cmdhist
BASH_ALIASES=()
BASH_ARGC=()
BASH_ARGV=()
BASH_CMDS=()

Creating shell variable:

$ SOME_VAR="test shell var"

This variable is defined only for the shell.

$ set | grep SOME_VAR

But not in the environment variables:

$ printenv | grep SOME_VAR 

Creating environment variable Shell variables can be turned into environment variables

$ export SOME_VAR

$ printenv | grep SOME_VAR

Environment variable can be turned back to shell variables

$ export -n SOME_VAR

Common environment variables

PATH – a list of directory paths. When the user types a command without providing the full path, this list is checked to see whether it contains a path that leads to the command.

HOME (Unix-like) - dicate where a user's home directory is located in the file system.

TERM – specifies the type of computer terminal or terminal emulator being used (e.g., vt100).

MAIL – used to indicate where a user's mail is to be found.

SHELL - default shell

PWD - prints current working directory

Reference and further reading

Is there a “.bashrc” equivalent file read by all shells?

What is the difference between 'env' and 'printenv'?

How to permanently set environmental variables

How To Read and Set Environmental and Shell Variables on a Linux VPS

env utility specification (The Open Group Base Specifications Issue 7, 2018 edition)

Introduction

Environment variables in Unix-like operating systems determine the behavior and access in the system. Some of the settings are contained within configuration settings, other are determined by user input. The shell keeps track of all the settings in the environment, that builds every time it starts a session with variables, defining system properties. Environment variables by convention are defined using capital letters.

The list of environmental variables is show by using commands env and printenv :

$ printenv
XDG_VTNR=7
LC_PAPER=en_GB.UTF-8
LC_ADDRESS=en_GB.UTF-8
XDG_SESSION_ID=c2
XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/aav
LC_MONETARY=en_GB.UTF-8
CLUTTER_IM_MODULE=xim

printenv can request for particular variable

$ printenv SHELL
/bin/bash

env can set variables like:

$ env test_var="The test"
$ echo $TEST_VAR
The test

Shell variables are shown with the set command:

$ set
BASH=/bin/bash
BASHOPTS=checkwinsize:cmdhist
BASH_ALIASES=()
BASH_ARGC=()
BASH_ARGV=()
BASH_CMDS=()

Creating shell variable:

$ SOME_VAR="test shell var"

This variable is defined only for the shell.

$ set | grep SOME_VAR

But not in the environment variables:

$ printenv | grep SOME_VAR 

Creating environment variable Shell variables can be turned into environment variables

$ export SOME_VAR

$ printenv | grep SOME_VAR

Environment variable can be turned back to shell variables

$ export -n SOME_VAR

Common environment variables

PATH – a list of directory paths. When the user types a command without providing the full path, this list is checked to see whether it contains a path that leads to the command.

HOME (Unix-like) - dicate where a user's home directory is located in the file system.

TERM – specifies the type of computer terminal or terminal emulator being used (e.g., vt100).

MAIL – used to indicate where a user's mail is to be found.

SHELL - default shell

PWD - prints current working directory

###Further reading

Is there a “.bashrc” equivalent file read by all shells?

What is the difference between 'env' and 'printenv'?

How to permanently set environmental variables

What is the difference in usage between shell variables and environment variables?

###External References

How To Read and Set Environmental and Shell Variables on a Linux VPS

env utility specification (The Open Group Base Specifications Issue 7, 2018 edition)

Environment Variables (The Open Group Base Specifications Issue 7, 2018 edition)

Adeed env utility specification (The Open Group Base Specifications Issue 7, 2018 edition)
Source Link

Introduction

Environment variables in Unix-like operating systems determine the behavior and access in the system. Some of the settings are contained within configuration settings, other are determined by user input. The shell keeps track of all the settings in the environment, that builds every time it starts a session with variables, defining system properties. Environment variables by convention are defined using capital letters.

The list of environmental variables is show by using commands env and printenv :

$ printenv
XDG_VTNR=7
LC_PAPER=en_GB.UTF-8
LC_ADDRESS=en_GB.UTF-8
XDG_SESSION_ID=c2
XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/aav
LC_MONETARY=en_GB.UTF-8
CLUTTER_IM_MODULE=xim

printenv can request for particular variable

$ printenv SHELL
/bin/bash

env can set variables like:

$ env test_var="The test"
$ echo $TEST_VAR
The test

Shell variables are shown with the set command:

$ set
BASH=/bin/bash
BASHOPTS=checkwinsize:cmdhist
BASH_ALIASES=()
BASH_ARGC=()
BASH_ARGV=()
BASH_CMDS=()

Creating shell variable:

$ SOME_VAR="test shell var"

This variable is defined only for the shell.

$ set | grep SOME_VAR

But not in the environment variables:

$ printenv | grep SOME_VAR 

Creating environment variable Shell variables can be turned into environment variables

$ export SOME_VAR

$ printenv | grep SOME_VAR

Environment variable can be turned back to shell variables

$ export -n SOME_VAR

Common environment variables

PATH – a list of directory paths. When the user types a command without providing the full path, this list is checked to see whether it contains a path that leads to the command.

HOME (Unix-like) - dicate where a user's home directory is located in the file system.

TERM – specifies the type of computer terminal or terminal emulator being used (e.g., vt100).

MAIL – used to indicate where a user's mail is to be found.

SHELL - default shell

PWD - prints current working directory

Reference and further reading

Is there a “.bashrc” equivalent file read by all shells?

What is the difference between 'env' and 'printenv'?

How to permanently set environmental variables

How To Read and Set Environmental and Shell Variables on a Linux VPS

env utility specification (The Open Group Base Specifications Issue 7, 2018 edition)

Introduction

Environment variables in Unix-like operating systems determine the behavior and access in the system. Some of the settings are contained within configuration settings, other are determined by user input. The shell keeps track of all the settings in the environment, that builds every time it starts a session with variables, defining system properties. Environment variables by convention are defined using capital letters.

The list of environmental variables is show by using commands env and printenv :

$ printenv
XDG_VTNR=7
LC_PAPER=en_GB.UTF-8
LC_ADDRESS=en_GB.UTF-8
XDG_SESSION_ID=c2
XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/aav
LC_MONETARY=en_GB.UTF-8
CLUTTER_IM_MODULE=xim

printenv can request for particular variable

$ printenv SHELL
/bin/bash

env can set variables like:

$ env test_var="The test"
$ echo $TEST_VAR
The test

Shell variables are shown with the set command:

$ set
BASH=/bin/bash
BASHOPTS=checkwinsize:cmdhist
BASH_ALIASES=()
BASH_ARGC=()
BASH_ARGV=()
BASH_CMDS=()

Creating shell variable:

$ SOME_VAR="test shell var"

This variable is defined only for the shell.

$ set | grep SOME_VAR

But not in the environment variables:

$ printenv | grep SOME_VAR 

Creating environment variable Shell variables can be turned into environment variables

$ export SOME_VAR

$ printenv | grep SOME_VAR

Environment variable can be turned back to shell variables

$ export -n SOME_VAR

Common environment variables

PATH – a list of directory paths. When the user types a command without providing the full path, this list is checked to see whether it contains a path that leads to the command.

HOME (Unix-like) - dicate where a user's home directory is located in the file system.

TERM – specifies the type of computer terminal or terminal emulator being used (e.g., vt100).

MAIL – used to indicate where a user's mail is to be found.

SHELL - default shell

PWD - prints current working directory

Reference and further reading

Is there a “.bashrc” equivalent file read by all shells?

What is the difference between 'env' and 'printenv'?

How to permanently set environmental variables

How To Read and Set Environmental and Shell Variables on a Linux VPS

Introduction

Environment variables in Unix-like operating systems determine the behavior and access in the system. Some of the settings are contained within configuration settings, other are determined by user input. The shell keeps track of all the settings in the environment, that builds every time it starts a session with variables, defining system properties. Environment variables by convention are defined using capital letters.

The list of environmental variables is show by using commands env and printenv :

$ printenv
XDG_VTNR=7
LC_PAPER=en_GB.UTF-8
LC_ADDRESS=en_GB.UTF-8
XDG_SESSION_ID=c2
XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/aav
LC_MONETARY=en_GB.UTF-8
CLUTTER_IM_MODULE=xim

printenv can request for particular variable

$ printenv SHELL
/bin/bash

env can set variables like:

$ env test_var="The test"
$ echo $TEST_VAR
The test

Shell variables are shown with the set command:

$ set
BASH=/bin/bash
BASHOPTS=checkwinsize:cmdhist
BASH_ALIASES=()
BASH_ARGC=()
BASH_ARGV=()
BASH_CMDS=()

Creating shell variable:

$ SOME_VAR="test shell var"

This variable is defined only for the shell.

$ set | grep SOME_VAR

But not in the environment variables:

$ printenv | grep SOME_VAR 

Creating environment variable Shell variables can be turned into environment variables

$ export SOME_VAR

$ printenv | grep SOME_VAR

Environment variable can be turned back to shell variables

$ export -n SOME_VAR

Common environment variables

PATH – a list of directory paths. When the user types a command without providing the full path, this list is checked to see whether it contains a path that leads to the command.

HOME (Unix-like) - dicate where a user's home directory is located in the file system.

TERM – specifies the type of computer terminal or terminal emulator being used (e.g., vt100).

MAIL – used to indicate where a user's mail is to be found.

SHELL - default shell

PWD - prints current working directory

Reference and further reading

Is there a “.bashrc” equivalent file read by all shells?

What is the difference between 'env' and 'printenv'?

How to permanently set environmental variables

How To Read and Set Environmental and Shell Variables on a Linux VPS

env utility specification (The Open Group Base Specifications Issue 7, 2018 edition)

added body with examples and links for further reading, excerpt small addition
Source Link
Loading
Link
Loading