What is a Computing Environment?
Computing environment is the Platform(Platform = Operating System+ Processor) where a user can run programs.
What is a Variable?
In computer science, a variable is a location for storing a value which can be a filename, text, number or any other data. It is usually referred to with its Symbolic name which is given to it while creation. The value thus stored can be displayed, deleted, edited and re-saved.
Variables play an important role in computer programming because they enable programmers to write flexible programs. As they are related to the Operating system that we work on, it is important to know some of them and how we can influence them.
So, what are Environment variables?
- Dynamic values which affect the processes or programs on a computer
- Exist in every operating system; types may vary
- Can be created, edited, saved and deleted
- Gives information about the system behavior
Environment variables can change the way a software/programs behaves.
E.g. $LANG environment variable stores the value of the language that the user understands. This value is read by an application such that a Chinese user is shown a Mandarin interface while an American user is shown an English interface.
Let's study some common environment variables -
This variable contains a colon (:)-separated list of directories in which your system looks for executable files.
When you enter a command on terminal, the shell looks for the command in different directories mentioned in the $PATH variable. If the command is found , it executes. Otherwise, it returns with an error 'command not found'.
Default path to the user's home directory
Path to the program which edits the content of files
User's unique ID
Default terminal emulator
Shell being used by the user
Accessing Variable values
In order to determine value of a variable , use the command
Variables are- Case Sensitive. Make sure that you type the variable name in the right letter case otherwise you may not get the desired results.
The 'env' command displays all the environment variables .
Creating New Variables
You can create your own user defined variable , with syntax
Again, bear in mind that variables are case-sensitive and usually they are created in upper case.
The following syntax can be used to remove a Variable from the system.
This would remove the Variable and its value permanently.
- Environment variables govern behavior of programs in your Operating System.
To display value of a variable
Displays all environment variables
Create a new variable
Remove a variable
To set value of an environment variable