Environment Variables.

Kajan
2 min readNov 18, 2023

--

Environmental variables are dynamic values that define the operating environment for processes and applications on a computer. They store information such as system paths, configuration settings, and user preferences, making it easier for software to adapt to different environments without requiring explicit paths or configurations.

Types of Environment variables:

  1. Global (System) Variables: These variables apply to the entire operating system and are accessible by all users. They often include system-wide configuration such as the location of system files or the directories and configuration settings.
  2. User-Specific Variables: Each user on an operating system can have their own set of environment variables. These variables customize the user’s environment according to their preferences.

Common Environment Variables:

PATH: Perhaps the most well-known environmental variable, the PATH variable specifies directories where the operating system should look for executable files. Adding a directory to the PATH allows you to run executable files from that location without specifying the full path.

TEMP (and TMP): Specifies directories for temporary files.

HOME (USERPROFILE in Windows): Points to the user’s home directory.

LANG: Determines the default language and localization settings. etc….

Accessing Environment Variables:

  1. In Unix-like operating systems (e.g., Linux), you can use the echo command to display the value of an environment variable, like echo $PATH.
  2. In Windows, you can use the echo command, but with % symbols, like echo %PATH%.

Setting and Modifying Environment Variables:

  1. In Unix-like systems, you can set environment variables in shell initialization files such as ~/.bashrc or globally in /etc/environment.
  2. In Windows, you can set environment variables through the System Properties or by using the set command.

Understanding and managing environment variables is crucial for configuring and customizing the behavior of an operating system. Whether you’re a system administrator, developer, or an everyday user, having a grasp of environment variables empowers you to tailor your computing environment to your specific needs.

--

--