{"id":5967,"date":"2024-12-05T00:01:40","date_gmt":"2024-12-04T18:31:40","guid":{"rendered":"https:\/\/www.veeble.com\/kb\/?p=5967"},"modified":"2025-03-04T12:00:03","modified_gmt":"2025-03-04T06:30:03","slug":"how-to-set-display-variable-and-enable-x11-forwarding-in-linux","status":"publish","type":"post","link":"https:\/\/www.veeble.com\/kb\/how-to-set-display-variable-and-enable-x11-forwarding-in-linux\/","title":{"rendered":"How to Set Display Variable and Enable X11 Forwarding in Linux"},"content":{"rendered":"\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/set-display-variable-and-enable-x11-forwarding-in-linux.jpeg\"><img loading=\"lazy\" decoding=\"async\" width=\"1792\" height=\"244\" data-id=\"5989\" src=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/set-display-variable-and-enable-x11-forwarding-in-linux.jpeg\" alt=\"set display variable and enable x11 forwarding in linux\" class=\"wp-image-5989\" srcset=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/set-display-variable-and-enable-x11-forwarding-in-linux.jpeg 1792w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/set-display-variable-and-enable-x11-forwarding-in-linux-300x41.jpeg 300w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/set-display-variable-and-enable-x11-forwarding-in-linux-1024x139.jpeg 1024w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/set-display-variable-and-enable-x11-forwarding-in-linux-768x105.jpeg 768w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/set-display-variable-and-enable-x11-forwarding-in-linux-1536x209.jpeg 1536w\" sizes=\"auto, (max-width: 1792px) 100vw, 1792px\" \/><\/a><\/figure>\n<\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p><a href=\"https:\/\/www.baeldung.com\/linux\/x11\" target=\"_blank\" rel=\"noopener\">X11<\/a> allows you to run GUI applications on a remote server while viewing them on your local machine. This guide will help you set the DISPLAY variable, enable X11 forwarding in Linux without making any confusions.<\/p>\n\n\n\n<pre class=\"wp-block-verse\" style=\"padding-top:0;padding-bottom:0\"><strong>What is the DISPLAY variable?<\/strong><br>The DISPLAY variable indicates where to show an application's GUI output, ensuring it appears on your local screen when running remotely.<\/pre>\n\n\n\n<p><\/p>\n\n\n<h2 class=\"wp-block-heading has-text-align-center\" id=\"steps-to-set-display-variable-in-linux\"><span style=\"text-decoration: underline\">Steps to Set Display Variable in Linux<\/span><\/h2>\n\n\n<div class=\"wp-block-group is-content-justification-center is-layout-constrained wp-block-group-is-layout-constrained\" style=\"border-width:1px;margin-top:0;margin-bottom:0;padding-top:0;padding-bottom:0\">\n<p>Before making changes, check the current value of your DISPLAY variable!!<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo $DISPLAY<\/code><\/pre>\n\n\n\n<p><span style=\"margin: 0px;padding: 0px\">The variable might not be set or configured correctly if you<\/span> see something like&nbsp;localhost:10.0&nbsp;or a blank output.<\/p>\n<\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>If the DISPLAY variable is empty or incorrect, run the command to set the DISPLAY variable:<\/p>\n\n\n\n<div class=\"wp-block-group is-layout-constrained wp-block-group-is-layout-constrained\" style=\"padding-top:0;padding-bottom:0\"><h6 class=\"wp-block-heading\" id=\"for-bash-shell-users\">For Bash Shell Users:<\/h6>\n\n\n<pre class=\"wp-block-code\"><code>export DISPLAY=localhost:10.0<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-3 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Screenshot-2024-12-04-182244.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1074\" height=\"119\" data-id=\"5981\" src=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Screenshot-2024-12-04-182244.png\" alt=\"set display variable in linux before enable x11 forwarding in linux by the command: export DISPLAY=localhost:10.0\" class=\"wp-image-5981\" srcset=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Screenshot-2024-12-04-182244.png 1074w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Screenshot-2024-12-04-182244-300x33.png 300w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Screenshot-2024-12-04-182244-1024x113.png 1024w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Screenshot-2024-12-04-182244-768x85.png 768w\" sizes=\"auto, (max-width: 1074px) 100vw, 1074px\" \/><\/a><\/figure>\n<\/figure>\n\n\n<h6 class=\"wp-block-heading\" id=\"for-cshell-csh-users\">For C-Shell (csh) Users:<\/h6>\n\n\n<pre class=\"wp-block-code\"><code>setenv DISPLAY localhost:10.0<\/code><\/pre>\n<\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>After setting the DISPLAY variable, verify it using the below command again:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo $DISPLAY<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n<h2 class=\"wp-block-heading has-text-align-center\" id=\"steps-to-enable-x11-forwarding-in-ssh\"><span style=\"text-decoration: underline\">Steps to Enable X11 Forwarding in SSH<\/span><\/h2>\n\n\n<p>To use X11 forwarding when connecting to a remote server, you must enable it in your SSH settings.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open the SSH configuration file on your local machine:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>nano \/etc\/ssh\/ssh_config<\/code><\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>Ensure the following lines are present and uncommented in the <em>\/etc\/ssh\/ssh\/ssh_config<\/em> file:<\/li>\n<\/ol>\n\n\n\n<p><code>ForwardX11 yes<\/code><br><code>ForwardX11Trusted yes<\/code><\/p>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-4 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/x11-forwarding.gif\"><img loading=\"lazy\" decoding=\"async\" width=\"1908\" height=\"576\" data-id=\"5983\" src=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/x11-forwarding.gif\" alt=\"after set display variable, enable x11  forwarding in linux by enabling the lines mentioned in the blog in the SSH config file.\" class=\"wp-image-5983\"\/><\/a><\/figure>\n<\/figure>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>Save the changes and restart your SSH session.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-5 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Screenshot-2024-12-04-183305.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1228\" height=\"116\" data-id=\"5984\" src=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Screenshot-2024-12-04-183305.png\" alt=\"restart ssh\/sshd after set display variable followed by enable x11 forward\" class=\"wp-image-5984\" srcset=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Screenshot-2024-12-04-183305.png 1228w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Screenshot-2024-12-04-183305-300x28.png 300w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Screenshot-2024-12-04-183305-1024x97.png 1024w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Screenshot-2024-12-04-183305-768x73.png 768w\" sizes=\"auto, (max-width: 1228px) 100vw, 1228px\" \/><\/a><\/figure>\n<\/figure>\n\n\n\n<p><\/p>\n\n\n<h2 class=\"wp-block-heading has-text-align-center\" id=\"testing-x11-forwarding-in-linux\"><span style=\"text-decoration: underline\">Testing X11 Forwarding in Linux<\/span><\/h2>\n\n\n<p>To connect to the remote server with X11 forwarding enabled, execute the following command after replacing the exact values (username, IP\/hostname, password) of your remote machine:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ssh -X username@remote_serverIP<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-6 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Screenshot-2024-12-04-190308.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1386\" height=\"645\" data-id=\"5987\" src=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Screenshot-2024-12-04-190308.png\" alt=\"SSH to machine with argument -x after set display variable followed by enable x11 forwarding in linux\" class=\"wp-image-5987\" srcset=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Screenshot-2024-12-04-190308.png 1386w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Screenshot-2024-12-04-190308-300x140.png 300w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Screenshot-2024-12-04-190308-1024x477.png 1024w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Screenshot-2024-12-04-190308-768x357.png 768w\" sizes=\"auto, (max-width: 1386px) 100vw, 1386px\" \/><\/a><\/figure>\n<\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>Test the setup by running a GUI application, such as gedit:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gedit<\/code><\/pre>\n\n\n\n<p>The configuration is successful if the GUI application appears on your local screen.<\/p>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-7 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Screenshot-2024-12-04-185803.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1897\" height=\"624\" data-id=\"5986\" src=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Screenshot-2024-12-04-185803.jpg\" alt=\"opening a GUI software after set display variable followed by enable x11 forwarding in linux\" class=\"wp-image-5986\" srcset=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Screenshot-2024-12-04-185803.jpg 1897w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Screenshot-2024-12-04-185803-300x99.jpg 300w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Screenshot-2024-12-04-185803-1024x337.jpg 1024w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Screenshot-2024-12-04-185803-768x253.jpg 768w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Screenshot-2024-12-04-185803-1536x505.jpg 1536w\" sizes=\"auto, (max-width: 1897px) 100vw, 1897px\" \/><\/a><\/figure>\n<\/figure>\n\n\n\n<div class=\"wp-block-uagb-separator uagb-block-315c17f2\"><div class=\"wp-block-uagb-separator__inner\" style=\"--my-background-image:\"><\/div><\/div>\n\n\n\n<p>Following this guide helps you set the DISPLAY variable, enable X11 forwarding, and allow you to connect remote GUI applications to run on your local machine easily. As a final tip, please ensure that your local machine has an X server installed (e.g., <a href=\"https:\/\/www.xquartz.org\/\" target=\"_blank\" rel=\"noopener\">XQuartz <\/a>for macOS, <a href=\"https:\/\/sourceforge.net\/projects\/xming\/\" target=\"_blank\" rel=\"noopener\">Xming<\/a> for Windows) if any errors appear in between the setup.<\/p>\n\n\n\n<div style=\"height:35px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-uagb-call-to-action uagb-block-7a429d45 wp-block-button\"><div class=\"uagb-cta__wrap\"><h3 class=\"uagb-cta__title\">Take Control of Your Hosting<\/h3><p class=\"uagb-cta__desc\">Get the performance you need at a price you&#8217;ll love. Explore our affordable VPS plans.<\/p><\/div><div class=\"uagb-cta__buttons\"><a href=\"https:\/\/www.veeble.com\/in\/vps-hosting\/\" class=\"uagb-cta__button-link-wrapper wp-block-button__link\" target=\"_blank\" rel=\"noopener noreferrer\">Choose Your Plan<svg xmlns=\"https:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\"><path d=\"M504.3 273.6l-112.1 104c-6.992 6.484-17.18 8.218-25.94 4.406c-8.758-3.812-14.42-12.45-14.42-21.1L351.9 288H32C14.33 288 .0002 273.7 .0002 255.1S14.33 224 32 224h319.9l0-72c0-9.547 5.66-18.19 14.42-22c8.754-3.809 18.95-2.075 25.94 4.41l112.1 104C514.6 247.9 514.6 264.1 504.3 273.6z\"><\/path><\/svg><\/a><\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to set Display variable and enable X11 forwarding in Linux with this easy to understand tutorial with screenshots.<\/p>\n","protected":false},"author":7,"featured_media":7725,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[5],"tags":[],"class_list":["post-5967","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux"],"uagb_featured_image_src":{"full":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/How-to-Set-Display-Variable-and-Enable-X11-Forwarding-in-Linux.jpg",1366,768,false],"thumbnail":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/How-to-Set-Display-Variable-and-Enable-X11-Forwarding-in-Linux-150x150.jpg",150,150,true],"medium":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/How-to-Set-Display-Variable-and-Enable-X11-Forwarding-in-Linux-300x169.jpg",300,169,true],"medium_large":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/How-to-Set-Display-Variable-and-Enable-X11-Forwarding-in-Linux-768x432.jpg",768,432,true],"large":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/How-to-Set-Display-Variable-and-Enable-X11-Forwarding-in-Linux-1024x576.jpg",1024,576,true],"1536x1536":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/How-to-Set-Display-Variable-and-Enable-X11-Forwarding-in-Linux.jpg",1366,768,false],"2048x2048":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/How-to-Set-Display-Variable-and-Enable-X11-Forwarding-in-Linux.jpg",1366,768,false]},"uagb_author_info":{"display_name":"Adrian Antony","author_link":"https:\/\/www.veeble.com\/kb\/author\/adrian\/"},"uagb_comment_info":0,"uagb_excerpt":"Learn how to set Display variable and enable X11 forwarding in Linux with this easy to understand tutorial with screenshots.","_links":{"self":[{"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/posts\/5967","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/comments?post=5967"}],"version-history":[{"count":14,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/posts\/5967\/revisions"}],"predecessor-version":[{"id":7738,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/posts\/5967\/revisions\/7738"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/media\/7725"}],"wp:attachment":[{"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/media?parent=5967"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/categories?post=5967"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/tags?post=5967"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}