Q100127: How to delete/unset environment variables



This article explains how to delete environment variables for supported versions of Windows, Mac and Linux.


Windows 10/11

  1. Type "env" in the Taskbar Search,
    and select Edit the system environment variables.
  2. Click the Environment Variables... button.
  3. Select the environment variable you want to delete and click Delete.
  4. Repeat step 4 as many times as necessary.
  5. Click OK.

NOTE: When deleting either user or system variables, you may need to log off and on again before your changes to environment variables take effect.



macOS has a few ways that environment variables could be set: launchd.conf, .plist, or shell config file. Make sure to delete the environment variable using all methods you used to create the environment variables and where you’ve stored them.

If you used the launchd.conf file to set environment variables:

  1. Open the Terminal app.
  2. Enter the following command and confirm your password when prompted:
    sudo vi /etc/launchd.conf 
  3. Use the arrow keys to move the cursor to the environment variable you want to delete.
    TIP: Environment variables use either of the following formats:
    setenv <VARIABLE> <VALUE>
    or export VARIABLE = value
  4. Delete the line by pressing the "d" key twice (dd) on the keyboard.
  5. To save and quit, type colon and "x" (:x) then press Enter on the keyboard.
    TIP: If you want to undo, press the escape key, colon and "u" (:u), and Enter.

If you used a .plist file to set environment variables:

  1. Open the ~/Library/LaunchAgents/my.environment.plist file with the editor of your choice, like TextEdit.
    NOTE: "my.environment" may be named differently; please check all files in ~/Library/LaunchAgents if unsure.
    TIP: To navigate to ~/Library/LaunchAgents, open Go to the folder with Command + Shift + G.
  2. Delete the entire line of the environment variable(s) and value(s) in the file. Environment variables will use the following format:
    launchctl setenv MY_VARIABLE my_value
  3. Save.

If you used a shell config file, see the On Linux section below for more information on how to delete them.

Restart your Mac to apply the changes.



The procedure for deleting an environment variable depends on what your default shell is.

  1. To get the name of the shell you are using, open a Terminal window and enter echo $SHELL.
  2. Depending on the output of the previous step, do one of the following:
  • If your shell is a csh or tcsh, delete any environment variable(s) and value(s) from the .cshrc or .tcshrc files.
    TIP: Environment variables use the following format: setenv VARIABLE value. For example: setenv NUKE_PATH /SharedDisk/Nuke


  • If your shell is a bash, ksh, or zsh, delete any environment variable(s) and value(s) from the .bashrc or .kshrc files
    TIP: Environment variables use the following format: export VARIABLE = value. For example: export NUKE_PATH=/SharedDisk/Nuke

NOTE: If you don’t want to delete your environment variables, comment them out to unset them. For example, if you’re using bash, add # in front of the environment variable.

NOTE: If you have set environment variables in any other files, make sure you delete or unset them as well.


    We're sorry to hear that

    Please tell us why