To modify environment variables in a Linux environment, you can use the export command in the terminal. Here are the steps to modify an environment variable:
-
Open your terminal.
-
Check the current value of the variable (if it exists):
echo $VARIABLE_NAME -
Modify the variable:
You can change the value of an existing variable or create a new one using theexportcommand. For example, to modify an existing variable or create a new one:export VARIABLE_NAME="new_value" -
Make the change persistent (optional):
If you want the change to persist across terminal sessions, add the export command to your shell's configuration file (e.g.,.bashrcfor Bash or.zshrcfor Zsh). Open the file in a text editor:nano ~/.zshrc # or ~/.bashrcAdd the export line at the end of the file:
export VARIABLE_NAME="new_value" -
Save and exit the editor. In
nano, you can do this by pressingCtrl+O,Enter, and thenCtrl+X. -
Apply the changes without restarting the terminal:
source ~/.zshrc # or source ~/.bashrc -
Verify the change:
echo $VARIABLE_NAME
This will show the updated value of the environment variable.
