To Set System-Wide Environment Variables in Linux
System-wide environment variables are configured in files such as `/etc/environment`
, `/etc/profile`
, `/etc/profile.d/`
, or `/etc/bash.bashrc`
. These variables are accessible to all users and remain persistent across system restarts. Setting a system-wide environment variable involves the following steps:
Following steps can be followed to do so:
Step 1: Open the terminal.
Step 2:
$ sudo -H vi /etc/environment
Step 3: Enter password.
Step 4: Add variable in the file opened.
NAME=Value
Step 5: Save and close the file.
Step 6: To apply the changes, log out and log in again
Environment Variables in Linux/Unix
Environment variables, often referred to as ENVs, are dynamic values that wield significant influence over the behavior of programs and processes in the Linux operating system. These variables serve as a means to convey essential information to software and shape how they interact with the environment. Every Linux process is associated with a set of environment variables, which guide its behavior and interactions with other processes.
Table of Content
- Accessing Environment Variables
- Scope of an environment variable
- Global Environment Variables
- Local Environment Variables
- Displaying Environment Variables
- How to Set Environment Variables in Linux?
- To Set User-Wide Environment Variables in Linux
- To Set System-Wide Environment Variables in Linux
- How to unset environment variables?
- Some commonly used ENVs in Linux