Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Creating Default Environment Variables for Your Linux Users

Focus mode
Creating Default Environment Variables for Your Linux Users - Amazon AppStream 2.0

You can create environment variables on a Linux Image Builder instance. Creating environment variables makes them available on streaming instances created from that image.

Note

On Linux fleet instances, environment variables set using the Image Assistant (GUI) tool and the default system environment variables are exported through the /etc/profile.d/appstream_system_vars.sh script. To access these environment variables, you must explicitly source the /etc/profile.d/appstream_system_vars.sh script in your applications.

To create environment variables for your users
  1. If the folder /etc/profile doesn’t exist, run the following command to create it:

    [ImageBuilderAdmin]$ sudo mkdir -p /etc/profile.d

  2. To create a new shell script file (for example, my-environment.sh) in this folder, run the following command:

    [ImageBuilderAdmin]$ vim my-environment.sh

  3. On first line of the script file, add the following content:

    #!/bin/sh

  4. For each subsequent line, add an export command to set the environment variables for your image. The following example adds $HOME/bin to the PATH variable:

    export PATH=”$HOME/bin:$PATH”

  5. Press the Esc key to return to command mode in vim, then run the following command to save your script and exit vim:

    :x

  6. Run the following command to allow the script to run as a program:

    [ImageBuilderAdmin]$ chmod +x my-environment.sh

PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.