How to modify environment variables?

0118

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:

  1. Open your terminal.

  2. Check the current value of the variable (if it exists):

    echo $VARIABLE_NAME
  3. Modify the variable:
    You can change the value of an existing variable or create a new one using the export command. For example, to modify an existing variable or create a new one:

    export VARIABLE_NAME="new_value"
  4. 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., .bashrc for Bash or .zshrc for Zsh). Open the file in a text editor:

    nano ~/.zshrc  # or ~/.bashrc

    Add the export line at the end of the file:

    export VARIABLE_NAME="new_value"
  5. Save and exit the editor. In nano, you can do this by pressing Ctrl+O, Enter, and then Ctrl+X.

  6. Apply the changes without restarting the terminal:

    source ~/.zshrc  # or source ~/.bashrc
  7. Verify the change:

    echo $VARIABLE_NAME

This will show the updated value of the environment variable.

0 Comments

no data
Be the first to share your comment!