Which command is used to display a list of all environment variables and their stored values?

Environment variables are named variables used to store a value, such as a specific file path. They can be used to influence Nuke’s behavior. For example, Nuke uses the information stored in them to define where to place certain files.

Setting Environment Variables

This section teaches you how to set environment variables, check if a particular environment variable exists, and display a list of set environment variables.

On Windows

1.   Right-click on My Computer and select Properties.
2.   Go to the Advanced tab.
3.   Click the Environment Variables button. The Environment Variables dialog opens.
4.   Click the New button under either User variables or System variables, depending on whether you want to set the variable for the current user or all users. To set environment variables for all users, you need to have administrator privileges.
5.   In the Variable name field, enter the name of the environment variable you want to set. For a list of the environment variables that Nuke understands, see Nuke Environment Variables.
6.   In the Variable value field, enter the value for the variable. The value can be a directory path, for example.
7.   Click OK.

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

On Mac

On Mac, you can use the launchd.conf file to set environment variables. You may need to create the launchd.conf file if it doesn’t already exist in the /etc/ directory.

Note:  If you only need to set an environment variable for a single session, or you don't want to use the Mac launchd.conf file, you can also set variables using the method described in the On Linux section.

Environment variables set using the launchd.conf file are read both when Nuke is launched from the Nuke icon and when it’s launched from the Terminal.

1.   Open a Terminal window.
2.   Create the /etc/launchd.conf file, if it doesn't already exist, and then add the environment variable(s) and value(s) to the file using the following format:

setenv <VARIABLE> <VALUE>

For example, to set two environment variables, NUKE_PATH and OFX_PLUGIN_PATH, to point to alternate locations:

setenv NUKE_PATH /SharedDisk/Nuke/

setenv OFX_PLUGIN_PATH /SharedDisk/OFX

For a list of the environment variables that Nuke understands, see Nuke Environment Variables.

Tip:  A handy command line tool for creating and editing files in the Terminal is nano. To start nano with the correct permissions, enter:
sudo nano /etc/launchd.conf

3.   To force the OS to read the launchd.conf file at startup, enter:

launchctl < /etc/launchd.conf; sudo launchctl < /etc/launchd.conf

4.   Restart your Mac to apply the changes.

On Linux

1.   The procedure for setting an environment variable depends on what your default shell is. To get the name of the shell you are using, launch a shell 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 shell, add the following command to the .cshrc or .tcshrc file in your home directory: setenv VARIABLE value. Replace VARIABLE with the name of the environment variable and value with the value you want to give it, for example setenv NUKE_PATH /SharedDisk/Nuke.

If your shell is a bash or ksh shell, add the following command to the .bashrc or .kshrc file in your home directory: export VARIABLE=value. Replace VARIABLE with the name of the environment variable and value with the value you want to give it, for example export NUKE_PATH=/SharedDisk/Nuke.

For a list of the environment variables that Nuke understands, see Nuke Environment Variables.

To Check if an Environment Variable Exists

From Inside Nuke

Press X in the Node Graph, check that TCL is enabled, and enter:

getenv <VARIABLE>

OR

Open the Script Editor and enter:

import os
print os.environ["VARIABLE"]

In both cases, VARIABLE should be replaced by the environment variable you're interested in. For example, NUKE_TEMP_DIR on Windows returns:

C:/Users/<current_user>/AppData/Local/Temp/nuke

In the Windows Environment

1.   Select Start > All Programs > Accessories > Command Prompt.
2.   In the command window that opens, enter echo %VARIABLE%. Replace VARIABLE with the name of the environment variable. For example, to check if NUKE_DISK_CACHE is set, enter echo %NUKE_DISK_CACHE%.

If the variable is set, its value is displayed in the command window.

In the Mac or Linux Environment

1.   Launch Terminal or a shell.
2.   Enter echo $VARIABLE. Replace VARIABLE with the name of the environment variable. For example, to check if NUKE_DISK_CACHE is set, enter echo $NUKE_DISK_CACHE.

If the variable is set, its value is displayed in the Terminal or shell window.

To Display a List of Set Environment Variables

On Windows

1.   Select Start > All Programs > Accessories > Command Prompt.
2.   In the command window that opens, enter set.

A list of all the environment variables that are set is displayed in the command window.

On Mac or Linux

1.   Launch Terminal or a shell.
2.   Enter printenv.

A list of all the environment variables that are set is displayed in the Terminal or shell window.

Which command is used to display all environment variables?

To list all the environment variables, use the command " env " (or " printenv "). You could also use " set " to list all the variables, including all local variables.

What is the command to list the environment variables and their values?

The printenv command displays the values of environment variables. If the name argument is specified, only the value associated with name is printed.

Which command displays all environment variables known to your shell and their values?

The “printenv” command displays the currently active environment variables and the previously specified environment variables in the shell. You can see the output of using the “printenv” command to display all the environment variables in the shell as per the snapshot below.

Which command is used to display all environment variables in Unix?

Using the printenv Command The printenv command-line utility displays the values of environment variables in the current shell. We can specify one or more variable names on the command line to print only those specific variables.