

# Create Your Linux-Based Images
<a name="create-linux-based-images"></a>

You can create Linux-based Amazon WorkSpaces Applications images by connecting to a Linux image builder, installing the applications you need, creating default application settings and environment variables, and using a command line interface (CLI) tool or Image Assistant (GUI) tool to add these applications to the application catalog. To open the GUI tool, search for **Image Assistant** in the list of applications.

**Topics**
+ [Creating Default Application Settings for Your Users](create-default-app-settings.md)
+ [Creating Default Environment Variables for Your Linux Users](create-default-variables-linux.md)
+ [Optimizing the Launch Performance of Your Linux Applications](optimize-launch-performance.md)
+ [Creating Session Scripts](create-session-scripts.md)
+ [Using the Image Assistant CLI Tool for Linux](image-assistant-cli.md)
+ [Enabling and Disabling Webcam Support](webcam-support.md)
+ [Enabling and Disabling Heavy File Sync Mode for Home Folders](heavy-file-sync.md)
+ [Tutorial: Create a Custom Linux-Based WorkSpaces Applications Image](tutorial-create-linux-image.md)
+ [Tutorial: Enable Japanese Support for Your Linux Images](enable-japanese-support-linux.md)

# Creating Default Application Settings for Your Users
<a name="create-default-app-settings"></a>

Follow these steps to create default application settings for your users.

**Topics**
+ [Step 1: Install Linux Applications on the Image Builder](#app-settings-image-install)
+ [Step 2: Create a TemplateUser Account](#app-settings-template-user)
+ [Step 3: Create Default Application Settings](#app-settings-image-create-default-app-settings)
+ [Step 4: Save Default Application Settings](#app-settings-image-save-default-app-settings)
+ [Step 5: Test Default Application Settings (optional)](#app-settings-image-test-applications)
+ [Step 6: Clean Up](#app-settings-image-finish)

## Step 1: Install Linux Applications on the Image Builder
<a name="app-settings-image-install"></a>

In this step, you connect a Linux image builder and install your applications on the image builder.

**To install applications on the image builder**

1. Connect to the image builder by doing either of the following: 
   + [Use the WorkSpaces Applications console](managing-image-builders-connect-console.md) (for web connections only)
   + [Create a streaming URL](managing-image-builders-connect-streaming-URL.md) (for web or WorkSpaces Applications client connections)
**Note**  
You will be logged in as an ImageBuilderAdmin user to the Linux GNOME desktop and have root admin privileges.

1. Install the applications that you need. For example, to install a Chromium browser from a public yum repo, first open the Terminal application, then run the following command:

   **[ImageBuilderAdmin]\$1 sudo yum update && sudo yum install chromium.x86\$164** 

## Step 2: Create a TemplateUser Account
<a name="app-settings-template-user"></a>

In this step, you create a TemplateUser account, which creates default application settings for your streaming users.

**To create a TemplateUser Account**

1. Create a TemplateUser account that has no root permissions. For example, in a Terminal window, run the following commands to create TemplateUser on the image builder:

   **[ImageBuilderAdmin]\$1 sudo useradd -m TemplateUser** 

   **[ImageBuilderAdmin]\$1 echo -e '<*password*>\$1n<*password*>\$1n' \$1 sudo passwd TemplateUser**

1. Switch to the TemplateUser account:

   **[ImageBuilderAdmin]\$1 su - TemplateUser** 

## Step 3: Create Default Application Settings
<a name="app-settings-image-create-default-app-settings"></a>

In this step, you create default application settings for your WorkSpaces Applications users. Doing this enables your users to get started with applications quickly during their WorkSpaces Applications streaming sessions, without the need to create or configure these settings themselves.

**To create default application settings for your users**

1. Launch the application that you want to create the default settings for. For example, in a Terminal window, run following command to launch Chromium browser:

    **[TemplateUser]\$1 chromium-browser**

1. Configure the settings of the application. For example, set the home page of the Chromium browser as **https://aws.amazon.com**.

1. Close the applications.

1. Log out:

   **[TemplateUser]\$1 logout** 

## Step 4: Save Default Application Settings
<a name="app-settings-image-save-default-app-settings"></a>

In this step, you copy the default application settings you added to the **/etc/skel/** directory, and make them available to your streaming users.

**To save default application settings**
+ Run the following command in a Terminal window to copy the default application settings for your streaming users:

   **[ImageBuilderAdmin]\$1 sudo cp -r -f /home/TemplateUser/. /etc/skel**

## Step 5: Test Default Application Settings (optional)
<a name="app-settings-image-test-applications"></a>

In this step, verify that the applications you've added run correctly, and the default application settings work as expected. 

**To test your applications and default settings on an image builder**

1. Create a test user that has no root permissions. For example, in a **Terminal** window, run the following commands to create **test-user** on the image builder:

   **[ImageBuilderAdmin]\$1 sudo useradd -m test-user**

   **[ImageBuilderAdmin]\$1 echo -e '*password*>\$1n<*password*>\$1n' \$1 sudo passwd test-user** 

1. Switch to the test user:

   **[ImageBuilderAdmin]\$1 su - test-user**

1. Launch the application (e.g., Chromium) as the test user:

   **[test-user]\$1 /usr/bin/chromium-browser** 

1. Verify that the default settings are available for the test user (e.g., the Chromium home page is https://aws.amazon.com/).

1. Log out:

   **[test-user]\$1 logout**

## Step 6: Clean Up
<a name="app-settings-image-finish"></a>

Finally, your last step is to clean up.

**To clean up**

1. Delete TemplateUser:

   **[ImageBuilderAdmin]\$1 sudo killall -u TemplateUser**

   **[ImageBuilderAdmin]\$1 sudo userdel -r TemplateUser**

1. Delete test-user (not required if you skipped step 5):

   **[ImageBuilderAdmin]\$1 sudo killall -u test-user**

   **ImageBuilderAdmin]\$1 sudo userdel -r test-user**

# Creating Default Environment Variables for Your Linux Users
<a name="create-default-variables-linux"></a>

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\$1system\$1vars.sh script. To access these environment variables, you must explicitly source the /etc/profile.d/appstream\$1system\$1vars.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]\$1 sudo mkdir -p /etc/profile.d** 

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

   **[ImageBuilderAdmin]\$1 vim my-environment.sh**

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

   **\$1\$1/bin/sh **

1. 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=”\$1HOME/bin:\$1PATH”**

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

   **:x**

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

   **[ImageBuilderAdmin]\$1 chmod \$1x my-environment.sh**

# Optimizing the Launch Performance of Your Linux Applications
<a name="optimize-launch-performance"></a>

If you are using the Image Assistant GUI tool, the tool optimizes launch performance for your applications automatically.

If you are using the Image Assistant CLI, use the following steps to optimize launch performance manually. When you create and add files to an application optimization manifest, the application will launch faster when first started on a new fleet instance. However, this also increases the time that it takes for the fleet instances to be made available to users. The optimization manifest is one line-delimited text file for every application.

You can create a manifest file (such as <*your-app*>-manifest.txt) either manually or by following with the steps below.

**To create a manifest file**

1. Make sure that the application that you are trying to optimize is launched and running.

1. From a terminal in the Linux image builder, run the following command: 

   **ps -ef \$1 grep <*application-process-name*>**

1. Search for the smallest PID number from the last step's output. This is the PID for the root parent process of the application.

1. Keep the application running and make sure to use the initial components required by your users. This ensures that these components are captured by the optimization process. 

1. Create a script file (e.g., `~/getfilestool.sh`) with the following content:

   ```
   #!/bin/bash
   ## usage getfilestool.sh $pid
   lsof -p $(pstree -p $1 | grep -o '([0-9]\+)' | grep -o '[0-9]\+' | tr '\012' ,)|grep REG | sed -n '1!p' | awk '{print $9}'|awk 'NF'
   ```

1. Make sure that the file can be run with the following command:

   **[ImageBuilderAdmin]\$1 chmod u\$1x \$1/getfilestool.sh**

1. Run the following command to capture all of the running files from the root parent process found in step 3, and save it to a temporary manifest file.

   **[ImageBuilderAdmin]\$1 sudo \$1/getfilestool.sh <*root-parent-pid*> > /tmp/<y*our-app*>-manifest.txt **

1. Verify the content of the optimization manifest, which is a line-delimited text file for every application.

You can specify the optimization manifest on a per-application basis by using the Image Assistant command line interface (CLI) tool. For more information, see [Using the Image Assistant CLI Tool for Linux](image-assistant-cli.md).

# Creating Session Scripts
<a name="create-session-scripts"></a>

WorkSpaces Applications provides on-instance session scripts on both Windows- and Linux-based streaming instances. For more information about session scripts, see [Use Session Scripts to Manage Your Amazon WorkSpaces Applications Users' Streaming Experience](use-session-scripts.md).

Session scripts are specified within an WorkSpaces Applications image. To locate the session scripts configuration file on a Linux instance, navigate to `/opt/appstream/SessionScripts/config.json`. The following code is a sample `config.json` file that specifies a session start script named “`test-session-start`” and a session end script named “`test-session-stop`” together with their runtime parameters. Make sure that the scripts referenced in `config.json` have run permissions and a command interpreter is defined (for example, \$1\$1/bin/bash). 

```
{
     "SessionStart": {
          "Executables": [
               {
                    "Context": "system",
                    "Filename": "/opt/appstream/SessionScripts/test-session-start",
                    "Arguments": "arg1",
                    "S3LogEnabled": true
               }
          ],
          "WaitingTime": 30
     },
     "SessionTermination": {
          "Executables": [
               { 
                    "Context": "system",
                    "Filename": "/opt/appstream/SessionScripts/test-session-stop", 
                    "Arguments": "arg2", 
                    "S3LogEnabled": true
               }
          ],
          "WaitingTime": 30
     }
}
```

# Using the Image Assistant CLI Tool for Linux
<a name="image-assistant-cli"></a>

On a Linux-based image builder, you can use the Image Assistant CLI tool **AppStreamImageAssistant** to create and manage your WorkSpaces Applications image. The tool is located at `/usr/local/appstream/image-assistant/AppStreamImageAssistant` with a symbolic link at `/bin/AppStreamImageAssistant`. This CLI tool for Linux supports many of the same operations as the Image Assistant CLI tool for Windows. For more information on these operations, see [Image Assistant CLI Operations for Creating and Managing Your Amazon WorkSpaces Applications Image](cli-operations-managing-creating-image-image-assistant.md).

# Enabling and Disabling Webcam Support
<a name="webcam-support"></a>

WorkSpaces Applications supports real-time audio-video (AV) by redirecting local webcam video input to WorkSpaces Applications streaming sessions. This capability enables your users to use their local webcam for video and audio conferencing within an WorkSpaces Applications streaming session. With real-time AV and support for real-time audio, your users can collaborate by using familiar video and audio conferencing applications without having to leave their WorkSpaces Applications streaming session.

To use this feature, you must use a Linux WorkSpaces Applications image that uses a Linux WorkSpaces Applications agent released on or after September 21, 2022.

**Note**  
Real-time AV is not supported for stream.standard.small instances powered by Rocky Linux or Red Hat Enterprise Linux. Users don't see the Camera and Mic icons on the client toolbar. 

The real-time AV feature is enabled by default for Linux streaming sessions. To configure webcam permissions for your users on a Linux image builder, create `/etc/appstream/appstream.conf` and add the following contents:

**Note**  
Specify **1** to enable webcam, or **0** to disable webcam.

```
[webcam]
permission = 1
```

# Enabling and Disabling Heavy File Sync Mode for Home Folders
<a name="heavy-file-sync"></a>

You can enable Amazon Simple Storage Service Home Folders options for your organization. When you enable Amazon S3 Home Folders for an WorkSpaces Applications stack, users of the stack can access a persistent storage folder during their application streaming sessions. No further conﬁguration is required for your users to access their home folder. Data stored by users in their home folder is automatically backed up to an Amazon S3 bucket in your AWS account, and is made available to those users in subsequent sessions. For more information, see [Enable and Administer Home Folders for Your WorkSpaces Applications Users](home-folders.md).

To ensure a smooth experience and address some existing limitations, where an inconsistent file sync might be observed when users save large text files from their streaming instances to their Home Folders, WorkSpaces Applications administrators can turn on the **heavy\$1sync** configuration option if large file uploads to Amazon S3 is a common user scenario while using WorkSpaces Applications. Turning on this option means that it might add some latency to the home folder file sync process, but completeness of all syncs to Amazon S3 is guaranteed.

This feature is available on all Red Hat Enterprise Linux images, and Linux WorkSpaces Applications images that use a Linux WorkSpaces Applications agent released on or after September 12, 2024.

The heavy sync feature is disabled by default for Red Hat Enterprise Linux and Rocky Linux streaming sessions. To configure heavy sync permission for your users on a Red Hat Enterprise Linux or Rocky Linux image builder, create `/etc/appstream/appstream.conf` and add the following contents:

**Note**  
Specify **1** to enable heavy sync, or **0** to disable heavy sync.

```
[storage]
heavy_sync = 1
```

# Tutorial: Create a Custom Linux-Based WorkSpaces Applications Image
<a name="tutorial-create-linux-image"></a>

This tutorial describes how to create a custom Linux-based Amazon WorkSpaces Applications image that contains applications which you can stream to your users.

**Important**  
Don't create a user named "as2-streaming-user" in your image builder. This is a reserved username for Fleet. If you create this username outside of the WorkSpaces Applications workflow, you might experience streaming issues in Fleets.

**Topics**
+ [Step 1: Install Linux Applications on the Image Builder](#tutorial-linux-image-install)
+ [Step 2: Generate Application Optimization Manifest File](#tutorial-linux-image-manifest)
+ [Step 3: Create an WorkSpaces Applications Application Catalog](#tutorial-linux-image-catalog)
+ [Step 4: Create Default Application Settings and Environment Variables](#tutorial-linux-image-create-default-app-settings)
+ [Step 5: Test Applications and Settings](#tutorial-linux-image-test-applications)
+ [Step 6: Finish Creating Your Image](#tutorial-linux-image-finish-create-image)
+ [Step 7 (Optional): Tag and Copy an Image](#tutorial-linux-image-tag-copy)
+ [Step 8: Clean Up](#tutorial-linux-image-finish)

## Step 1: Install Linux Applications on the Image Builder
<a name="tutorial-linux-image-install"></a>

In this step, you connect a Linux image builder and install your applications on the image builder.

**To install applications on the image builder**

1. Connect to the image builder by doing either of the following: 
   + [Use the WorkSpaces Applications console](managing-image-builders-connect-console.md) (for web connections only)
   + [Create a streaming URL](managing-image-builders-connect-streaming-URL.md) (for web or WorkSpaces Applications client connections)
**Note**  
You will be logged in as an ImageBuilderAdmin user to the Linux GNOME desktop and have root admin privileges.

1. Install the applications that you need. For example, to install a Chromium browser from a public yum repo, first open the Terminal application, then run the following command:

   **[ImageBuilderAdmin]\$1 sudo yum update && sudo yum install chromium.x86\$164** 
**Note**  
Download and install applications only from sites that you trust.

## Step 2: Generate Application Optimization Manifest File
<a name="tutorial-linux-image-manifest"></a>

In this step, you generate a manifest file for each application you installed in step 1.

**To generate a manifest file for optimizing the launch performance of an application**

1. Make sure the application (e.g., Chromium) that you are trying to optimize is launched and running.

1. In a Terminal window, run the following command to list processes related to the application:

   **[ImageBuilderAdmin]\$1 ps -ef \$1 grep chromium **

1. Find the root parent PID from the output of the command above. The following is an example output, and the root parent PID is 16712:  
**Example**  

   ```
   [ImageBuilderAdmin]$ ps -ef | grep chromium
   
   ImageBu+ 16712 4128 0 Aug26 ? 00:00:44 /usr/lib64/chromium- browser/chromium-browser --enable-plugins --enable-extensions -- enable-user- scripts --enable-printing --enable-gpu-rasterization -- enable-sync --auto-ssl- client-auth
   
   ImageBu+ 16726 16712 0 Aug26 ? 00:00:00 /usr/lib64/chromium- browser/chromium-browser --type=zygote --no-zygote-sandbox ImageBu+ 16727 16712 0 Aug26 ? 00:00:00 /usr/lib64/chromium- browser/chromium- browser --type=zygote
   
   ImageBu+ 16731 16727 0 Aug26 ? 00:00:00 /usr/lib64/chromium- browser/chromium-browser --type=zygot
   ```

1. Keep the application running and make sure to use the initial components required by your users. This ensures that these components are captured by the optimization process. 

1. Create script file (e.g., `~/getfilestool.sh`) with the following content:

   ```
   #!/bin/bash
   ## usage getfilestool.sh $pid
   lsof -p $(pstree -p $1 | grep -o '([0-9]\+)' | grep -o '[0-9]\+' | tr '\012' ,)|grep REG | sed -n '1!p' | awk '{print $9}'|awk 'NF'
   ```

1. Verify that the file can be run by running the following command:

   **[ImageBuilderAdmin]\$1 chmod u\$1x \$1/getfilestool.sh** 

1. Run the following command to capture all running files from the root parent process found in step 3 above, and save it to a temporary manifest file:

   **[ImageBuilderAdmin]\$1 sudo \$1/getfilestool.sh 16712 > /tmp/chromium-manifest.txt **

1. Verify the content of the optimization manifest, which is a line-delimited text file for each application.

## Step 3: Create an WorkSpaces Applications Application Catalog
<a name="tutorial-linux-image-catalog"></a>

In this step, you use the CLI tool `AppStreamImageAssistant` on the image builder to create an WorkSpaces Applications application catalog by specifying applications for your image. For each application that you plan to stream, you can specify the name, display name, executable ﬁle to launch, and icon to display.

**To create an WorkSpaces Applications application catalog**

1. From the image builder desktop, open **Terminal** either from the side panel or by opening the app grid.

1. Run **AppStreamImageAssistant --help** to see the list of available commands. You will use these commands to add applications and create an Image. 

1. Run the following command to add an installed application (e.g., Chromium) to the application list for WorkSpaces Applications users:

   ```
   AppStreamImageAssistant add-application \
    --name Chromium \
    --absolute-app-path /usr/lib64/chromium-browser/chromium-browser \
    --display-name Chromium \
    --absolute-icon-path /usr/share/icons/hicolor/256x256/apps/chromium-browser.png \
    --absolute-manifest-path /tmp/chromium-manifest.txt
   ```

   Alternatively, run the following command:

   ```
   AppStreamImageAssistant add-application \
    --name="Chromium" \
    --absolute-app-path="/usr/lib64/chromium-browser/chromium-browser" \
    --display-name="Chromium" \
    --absolute-icon-path="/usr/share/icons/hicolor/256x256/apps/chromium-browser.png" \
    --absolute-manifest-path="/tmp/chromium-manifest.txt"
   ```

1. To add more applications, repeat step 3 for each additional application.

1. To see the list of applications that have been added in the catalog, along with metadata like icon paths and launch parameters, run the following command:

   **AppStreamImageAssistant list-applications**

1. To remove applications from the catalog, run the following command:

   **AppStreamImageAssistant remove-application –-name *application\$1name***

## Step 4: Create Default Application Settings and Environment Variables
<a name="tutorial-linux-image-create-default-app-settings"></a>

In this step, you create default application settings and environment variables for your WorkSpaces Applications users. Doing this enables your users to get started with applications quickly during their WorkSpaces Applications streaming sessions, without the need to create or configure these settings themselves.

**To create default application and environment variables for your users**

1. Launch the application that you want create the default settings for. For example, in a Terminal window, run following command to launch Chromium browser:

    **[ImageBuilderAdmin]\$1 chromium-browser**

1. Configure the settings of the application. For example, set the home page of the Chromium browser as **https://aws.amazon.com**.

1. Make sure the Chromium application is closed, and then run the following commands to copy the configuration for Chromium to **/etc/skel**:

   **[ImageBuilderAdmin]\$1 sudo mkdir /etc/skel/.config**

   **[ImageBuilderAdmin]\$1 sudo cp -R \$1/.config/chromium /etc/skel/.config** 

1. Set the environment variables and add it to the script file. For example, run the following commands:

   **[ImageBuilderAdmin]\$1 echo "export *FOO*=*BAR*" \$1 sudo tee -a /etc/profile.d/myenvvars.sh** 

   **[ImageBuilderAdmin]\$1 sudo chmod \$1x /etc/profile.d/myenvvars.sh** 

## Step 5: Test Applications and Settings
<a name="tutorial-linux-image-test-applications"></a>

In this step, verify that the applications you've added run correctly, and the default application settings and environment variables work as expected. 

**To test your applications and default settings on an image builder**

1. Create a test user that has no root permissions. For example, in a **Terminal** window, run the following commands to create **test-user** on the image builder:

   **[ImageBuilderAdmin]\$1 sudo useradd -m test-user**

   **[ImageBuilderAdmin]\$1 echo -e 'Pa55w0rdas2\$1\$1\$1\$1nPa55w0rdas2\$1\$1\$1\$1n' \$1 sudo passwd test-user** 

1. Switch to the test user:

   **[ImageBuilderAdmin]\$1 su - test-user**

1. Launch the application (e.g., Chromium) as the test user:

   **[test-user]\$1 /usr/bin/chromium-browser** 

1. Verify that the default settings are available for the test user (e.g., the Chromium home page is https://aws.amazon.com/).

1. Verify that the environment variables are available for the test user. For example, run the following command:

   **[test-user]\$1 echo \$1*FOO***

   This command should display the output ***BAR*** in the terminal.

1. Run the following commands to delete the test user before creating an image from this image builder: 

   **\$1 logout test user**

   **[test-user]\$1 logout**

   **\$1 kill test user's running processes**

   **[ImageBuilderAdmin]\$1 sudo killall -u test-user**

   **\$1 delete user**

   **[ImageBuilderAdmin]\$1 sudo userdel -r test-user**

## Step 6: Finish Creating Your Image
<a name="tutorial-linux-image-finish-create-image"></a>

In this step, choose an image name and finish creating your image. 

**To create the image**

1. In a **Terminal** window, create an image from your Image Builder by running **AppStreamImageAssistant create-image**. This image contains your installed and registered applications, plus any session scripts and default application settings that you have configured.

   To see the list of available options, run **AppStreamImageAssistant create-image --help**. For more information, see the **create-image** operation in [Create Your Amazon WorkSpaces Applications Image Programmatically by Using the Image Assistant CLI Operations](programmatically-create-image.md).

1. The remote session disconnects after a few moments. When the **Lost Connectivity** message appears, close the browser tab. While the image is created, the image builder status appears as **Snapshotting**. You cannot connect to the image builder until this process finishes. 

1. Return to the console and navigate to **Images**, **Image Registry**. Verify that your new image appears in the list.

   While your image is being created, the image status in the image registry of the console appears as **Pending**. You can't connect to images that are in a **Pending** status. 

1. Choose the **Refresh** icon to update the status. After your image is created, the image status changes to **Available** and the image builder is automatically stopped.

   To continue creating images, start the image builder and connect to it from the console, or create a new image builder.

## Step 7 (Optional): Tag and Copy an Image
<a name="tutorial-linux-image-tag-copy"></a>

You can add one or more tags to an image during image creation or after you create an image. You can also copy the image within the same Region or to a new Region within the same Amazon Web Services account. Copying a source image results in an identical but distinct destination image. AWS does not copy any user-defined tags, however. Also, you can only copy custom images that you create, not the base images that are provided by AWS. 

**Note**  
You can copy up to two images at the same time to a destination. If the destination to which you are copying an image is at the image limit, you receive an error. To copy the image in this case, you must first remove images from the destination. After the destination is below the image quota (also referred to as limit), initiate the image copy from the source Region. For more information, see [Amazon WorkSpaces Applications Service Quotas](limits.md).

**To add tags to an existing image**

1. In the navigation pane, choose **Images**, **Image Registry**. 

1. In the image list, select the image to which you want to add tags.

1. Choose **Tags**, choose **Add/Edit Tags**, and then choose **Add Tag**. Specify the key and value for the tag, and then choose **Save**.

For more information, see [Tagging Your Amazon WorkSpaces Applications Resources](tagging-basic.md).

**To copy an image**

Copying an image across geographically diverse regions enables you to stream applications from multiple regions based on the same image. By streaming your applications in closer proximity to your users, you can improve your users' experience streaming applications with WorkSpaces Applications.

1. In the navigation pane, choose **Images**, **Image Registry**. 

1. In the image list, select the image that you want to copy.

1. Choose **Actions**, **Copy**.

1. In the **Copy Image** dialog box, specify the following information, and then choose **Copy Image**:
   + For **Destination region**, choose the region to which to copy the new image. 
   + For **Name**, specify a name that the image will have when it is copied to the destination. 
   + For **Description** (optional), specify a description that the image will have when it is copied to the destination. 

1. To check on the progress of the copy operation, return to the console and navigate to **Images**, **Image Registry**. Use the navigation bar to switch to the destination region (if applicable), and confirm that your new image appears in the list of images.

   The new image first appears with a status of **Copying** in the image registry of your console. After the image is successfully created, the status of the image changes to **Available**, which means that you can use the image to launch a stack and stream your applications. 

## Step 8: Clean Up
<a name="tutorial-linux-image-finish"></a>

Finally, you can stop your running image builders to free up resources and avoid unintended charges to your account. We recommend stopping any unused, running image builders. For more information, see [WorkSpaces Applications Pricing](https://aws.amazon.com/appstream2/pricing/).

**To stop a running image builder**

1. In the navigation pane, choose **Images**, **Image Builders**, and select the running image builder instance.

1. Choose **Actions**, **Stop**.

# Tutorial: Enable Japanese Support for Your Linux Images
<a name="enable-japanese-support-linux"></a>

This tutorial describes how to enable Japanese support for a Linux image. This enables applications on the image to display Japanese characters, and streaming users to use the Japanese input method in the streaming sessions from the image.

**Topics**
+ [Step 1: Install Japanese Font and Input Method](#tutorial-japanese-font)
+ [Step 2: Set the System Time Zone](#tutorial-japanese-zone)
+ [Step 3: Set the System Locale and Display Language](#tutorial-japanese-locale)
+ [Step 4: Configure the Input Methods](#tutorial-japanese-input)
+ [Step 5: Set the Keyboard Layout](#tutorial-japense-keyboard)
+ [Step 6: Verify on Image Builder](#tutorial-japense-verify)
+ [Step 7: Create the Image](#tutorial-japanese-create)

## Step 1: Install Japanese Font and Input Method
<a name="tutorial-japanese-font"></a>

In this step, you connect a Linux image builder and install the font and input method packages of your choice.

**To install Japanese font and input method**

1. Connect to the image builder by doing either of the following: 
   + [Use the WorkSpaces Applications console](managing-image-builders-connect-console.md) (for web connections only)
   + [Create a streaming URL](managing-image-builders-connect-streaming-URL.md) (for web or WorkSpaces Applications client connections)
**Note**  
You will be logged in as an ImageBuilderAdmin user to the Linux GNOME desktop and have root admin privileges.

1. Install the font and input method that you need. To do this, open the Terminal application, then run the following commands:

   **sudo yum install vlgothic-p-fonts.noarch**

   **sudo yum install ibus-kkc.x86\$164**

1. In addition to the above commands, for Rocky Linux and Red Hat Enterprise Linux, run the following command:

   **sudo yum install glibc-langpack-ja**

## Step 2: Set the System Time Zone
<a name="tutorial-japanese-zone"></a>

To set the system time zone, run the following command:

**sudo timedatectl set-timezone "Asia/Tokyo"**

## Step 3: Set the System Locale and Display Language
<a name="tutorial-japanese-locale"></a>

To set the system locale and display language, run the following commands. 

**To set the system locale and display language**

1. Update the `cloud-init config` file by running the command **sudo vim /etc/cloud/cloud.cfg**, and change **locale** to **locale: ja\$1JP.utf8**, then save and close the file.

1. Update the system settings by running **sudo localectl set-locale LANG=ja\$1JP.utf8**.

1. Update the Gnome shell settings by running **sudo gsettings set org.gnome.system.locale region "ja\$1JP.utf8"**.

## Step 4: Configure the Input Methods
<a name="tutorial-japanese-input"></a>

Configure the input methods for the application you want to add to the image. For more information about how install an application, generate a manifest file, and create default settings, see [Tutorial: Create a Custom Linux-Based WorkSpaces Applications Image](tutorial-create-linux-image.md). In this step, we assume that you’ve already installed the application Firefox, which is located at `/usr/local/firefox/firefox`.

**To configure the input methods**

1. Create a script by running the command **sudo vim /usr/local/bin/update-input-method.sh**, and add the following content to the script:

   ```
   #!/bin/bash
   
   function start_process()
   {
       command=$1
       process_name=$2
   
       process_count=$(pgrep $process_name -c)
       echo "$(date) current $process_name count: $process_count"
       while [ $process_count -lt 1 ]
       do
           echo "$(date) starting $process_name"
           eval $command
           sleep 1
           process_count=$(pgrep $process_name -c)
       done
       echo "$(date) $process_name started"
   }
   
   start_process "ibus-daemon --xim &" "ibus-daemon"
   start_process "/usr/libexec/ibus-engine-kkc --ibus &" "ibus-engine-kkc"
   
   gsettings set org.gnome.desktop.input-sources sources "[('ibus','kkc'), ('xkb', 'us')]"
   gsettings set org.gnome.desktop.wm.keybindings switch-input-source "['<Control>space']"
   gsettings set org.gnome.desktop.wm.keybindings switch-input-source-backward "['<Shift><Control>space']"
   
   echo "$(date) updated input source and switch shortcut"
   ```

   In the script above, the first input source (‘ibus’, ‘kkc’) is the default input method. You can change the default input method by changing the order of input sources. In addition, “Control\$1Space” and “Shift\$1Control\$1Space” are specified as shortcut key combinations for switching between input methods. You can specify your own key combinations that your users can use to switch input methods during streaming sessions.

1. Create the script for launching the application (Firefox) that you will add to the image. To do this, run the command **sudo vim /usr/local/bin/firefox-jp.sh**, then add the following content to the script:

   ```
   #!/bin/bash
   
   # Gather required environment variables from the GNOME shell session
   while IFS= read -r -d $'\0' env_var; do
       case "$env_var" in
           DBUS_SESSION_BUS_ADDRESS=*|\
           GTK_IM_MODULE=*|\
           QT_IM_MODULE=*|\
           XMODIFIERS=*|\
           XAUTHORITY=*)
               echo "$env_var"
               export "$env_var"
               ;;
       esac
   done < "/proc/$(pgrep -u as2-streaming-user gnome-shell | head -n1)/environ"
   
   /usr/local/bin/update-input-method.sh > /var/tmp/update-input-method.log 2>&1 &
   
   /usr/local/firefox/firefox &
   ```

1. Add run permission to both scripts by running following the commands:

   **sudo chmod \$1x /usr/local/bin/update-input-method.sh**

   **sudo chmod \$1x /usr/local/bin/firefox-jp.sh**

1. If you already created the optimization manifest file for the application run the following commands to add the application launch script to the application catalog:

   ```
   sudo AppStreamImageAssistant add-application \
   --name firefox \
   --absolute-app-path /usr/local/bin/firefox-jp.sh \
   --display-name firefox \
   --absolute-icon-path /usr/local/firefox/browser/chrome/icons/default/default128.png \
   --absolute-manifest-path /tmp/firefox-manifest.txt
   ```

Alternatively, you can also configure the input methods by adding the script update-input-method.sh as a separate application to the application catalog for the image. During streaming sessions, your users can launch this application to enable Japanese input, and switch between input methods with specified shortcut keys within the same session.

## Step 5: Set the Keyboard Layout
<a name="tutorial-japense-keyboard"></a>

Set the keyboard layout to match the keyboards your users will use during streaming sessions. You can use the command **localectl list-keymaps** to list all the available keymaps, and use the command **sudo localectl set-keymap jp106** to set the keymap to the Japanese keyboard of 106 keys, for example.

## Step 6: Verify on Image Builder
<a name="tutorial-japense-verify"></a>

To verify on image builder, first reboot the image builder by running the command **sudo shutdown -r now**. After reboot, connect to the image builder again, and verify that everything, including time zone, locale, language, and input method, works as expected.

## Step 7: Create the Image
<a name="tutorial-japanese-create"></a>

Create the image on the image builder. For more information, see [Tutorial: Create a Custom Linux-Based WorkSpaces Applications Image](tutorial-create-linux-image.md). Make sure to create default application settings, including the regional settings you just configured. For more information, see "Creating Default Application Settings for Your Users" in [Create Your Linux-Based Images](create-linux-based-images.md).

All of the Linux fleet instances created from this image will have the same default time zone, locale, language, and input method settings that you configured for the image.