How to enable GUI in AWS ec2 instance?

By default, an AWS EC2 instance running Amazon Linux 2 OS does not come with a GUI. However, you can enable GUI in AWS EC2 instance by following the below steps –

Step 1: Connect to your EC2 instance.

Step 2: Check your OS name

Step 3: Update your EC2 instance packages

Step 4: Install MATE packages.

Step 5: Define MATE as your default desktop.

Step 6: Install TigerVNC packages:

Step 7: Configure a VNC-specific password containing 6 to 8 characters for this user.

Step 8: Start the VNC Server on display number 1.

Step 9: Download and install the TigerVNC software on your local computer using the below link
https://tigervnc.org/

Step 10: On your local computer, use SSH to connect to your instance while creating a tunnel to forward all traffic on local port 5901/TCP (VNC) to the instance’s VNC server:

Step 11: Open the VNC Client on your local computer. When asked for the VNC server hostname, enter localhost:1 and then connect to it.

Step 12: Enter the VNC password you set up in step 2 of the Install TigerVNC section. If an alert appears stating that the connection isn’t secure, disregard it.