====== Installing and configuring an X server ====== This detailed and easy-to-understand page will help you **set up things correctly on your own**, and help you **understand what you are doing** Or you can ask somebody to quickly configure everything for you, and keep on believing that things work by magic... ===== What is an X server? ===== * An //X server// **is not** a server for distributing your perfect models output! * An //X server// **is** basically a program running on your **local** computer that understands the [[https://en.wikipedia.org/wiki/X_Window_System_core_protocol|X Windows System protocol]] used by **Linux computers** (**local** computer, or **remote** Linux servers) to generate graphics, and that can //render// (i.e. display) the graphics generated **remotely** on your **local** computer * This page will mention a //''DISPLAY'' variable// several times: the X server needs this in order to know **where to display the graphics**! ===== What do we mean exactly with Local and Remote computers? ===== This page will very often mention **local computers**, and **remote computers**: * The **local computer** is the desktop or laptop you are interacting with (using a screen+mouse+keyboard) * The local computer can be a **Linux, Windows or Mac (i.e //OS X//) computer** * The **remote computer or server** is another computer that you also want to interact with (using the screen+mouse+keyboard of your local computer) * [[other:ssh#connecting_to_servers_commonly_used_by_lsce_users|Some servers used by LSCE users]] * We only consider on this page the case of a **remote //Linux// machine** that **requires a local running //X server//** * **Remote Linux machine** can mean several things: * It can be another operating system running inside **a [[https://en.wikipedia.org/wiki/Virtual_machine|Virtual Machine]] on your local computer** * We mostly consider on this page the case of a **Linux virtual machine** using [[other:win10wsl|Windows Subsystem for Linux (WSL)]] on a **local Windows computer**, but this can apply to other configurations * It can be a **distant Linux computer or server** in your building, or a high performance Linux computer in a computing center on the other side of the Earth. It could also be a Linux virtual machine in the //Cloud// ===== Using an X server on Linux ===== You don't need to do anything special! Linux computers come pre-configured with a running //X server// that will display the graphics generated locally and on remote Linux servers ===== Using an X server on Windows ===== There are several available X servers, and applications that will allow //X forwarding// from a remote server to your local X server ==== Using X forwarding in a Windows Powershell ==== **You have to type ''$env:DISPLAY = "localhost:0"'' before connecting** using ''ssh -Y remote server'' (''-X'' will not work), in order to have the ''DISPLAY'' variable correctly defined on the remote server PS C:\> ssh -X obelix [...] >echo $DISPLAY DISPLAY: Undefined variable. >logout Connection to obelix closed. PS C:\> $env:DISPLAY PS C:\> $env:DISPLAY = "localhost:0" PS C:\> $env:DISPLAY localhost:0 PS C:\> ssh -X obelix [...] Warning: untrusted X11 forwarding setup failed: xauth key data not generated [...] >echo $DISPLAY DISPLAY: Undefined variable. PS C:\> ssh -Y obelix [...] Warning: No xauth data; using fake authentication data for X11 forwarding. [...] >echo $DISPLAY localhost:42.0 >xterm& [1] 30038 ==== Installing VcXsrv ==== ''VcXsrv'' is **pre-installed on the LSCE Windows computers**! * You may want to check if a more recent version is available * You surely want to follow the configuration steps, in order to get the best possible settings to work with PuTTY! Type: free Download the installer from [[https://sourceforge.net/projects/vcxsrv/|VcXrsv]] and install ''VcXsrv''. === VcXsrv Configuration === You need to configure ''VcXsrv'' to work in //multiple windows// mode. The following steps will show you how to create a shortcut on your desktop to start ''VcXsrv'' in this appropriate mode * Start the //configuration tool//: ''Start'' => ''VcXsrv'' => ''Xlaunch'' * Select ''Multiple windows'', then ''Next'' * Select ''Start no client'', then ''Next'' * Keep the default ''Clipboard'' settings, uncheck ''Native opengl'', then ''Next'' * You can check the [[other:x_conf#opengl_related_settings|OpenGL discussion section]] if you have time... * Click on ''Save configuration'' and save an ''X_Server.xlaunch'' configuration file on your Desktop, then ''Terminate''.\\ You should now have a new ''X_Server'' icon/shortcut on your Desktop * Start the server by double-clicking on the new ''X_Server'' icon * It will seem that nothing happens, but an ''X'' icon will appear in the right side of the taskbar (you may have to look for it in the //Display hidden icons// pull-up menu). Your computer is now ready to display remote graphics!\\ {{ :other:vcxsrv_x.png?direct |}} * The X server will stop when you close your Windows session or restart the computer. Do not forget to click on the ''X_Server'' icon on your desktop if you know that you will need an X server later * FIXME Document how to automatically start the X server... * Note: you can right-click on the ''X'' icon and select ''Exit...'' if you need to quit the X server ==== Installing x410 ==== [[https://token2shell.com/x410/|x410]] is a **low cost** commercial //X server// that can be directly installed from the [[https://www.microsoft.com/store/productId/9NLP712ZMN9Q|Microsoft store]]. This is an //X server//, and you will get the same functionalities as what is already provided for free by [[other:x_conf#installing_vcxsrv|VcXsrv]], **but**: * Once installed, ''x410'' will be automatically updated by the Microsoft Store application * If you move to another computer, you can install ''x410'' again by just [[other:win10config#connecting_to_the_microsoft_store|Connecting the Microsoft Store to your MS account]] on the new computer. No need to buy ''x410'' again ! * There seems to be more (useful) updates than for ''VcXsrv'' * The interface is more modern, with more options, and there is a lot of useful information on the web site * The ''x410'' name is easier to remember! :-D Type: commercial Buy and install ''x410'' from the [[https://www.microsoft.com/store/productId/9NLP712ZMN9Q|Microsoft store]] === x410 configuration === * Start ''x410'': ''Start'' => ''X410'' * It will seem that nothing happens, but an ''X'' icon will appear in the right side of the taskbar (you may have to look for it in the //Display hidden icons// pull-up menu). Your computer is now //almost// ready to display remote graphics!\\ {{ :other:x410_x.png?direct |}} * Right-click on the ''X'' icon to open the **X410 settings** * Select ''Auto copy to Windows after selection''\\ {{ :other:x410_settings.png?direct |}} and click somewhere else on the desktop to close the settings * It is possible to **automatically start ''x410''** when you open your session! Otherwise, it will stop when you close your Windows session or restart the computer, and you will have to restart it by hand (''Start'' => ''X410'') if you know that you will need an X server later * Open the **Windows Task Manager** (Right-click on ''Start'' and select ''Task Manager'') * Go to the ''Startup'' panel (if there are no panels, select ''More details'') * Right-click on ''X140'' and select ''Enabled'' * Note: if you need to quit the //X server//, you can right-click on the ''X'' icon, and then click on the //Display// number at the lower left (usually ''0'') and select ''Shut down'' ===== Using an X server on a Mac ===== ==== Installing XQuartz ==== Type: free Download the installer from [[https://www.xquartz.org|XQuartz]] and install it === XQuartz configuration === Nothing to configure! The ''XQuartz'' //X server// will be automatically started, if a graphical application needs it! Check the [[https://support.apple.com/guide/terminal/script-management-with-launchd-apdc6c1077b-5d5d-4d35-9c19-60f2397b2369/mac|launchd documentation]] if you need more details $ launchctl list | grep quartz - 0 org.xquartz.startx ===== Configuration on the remote Linux server ===== ==== If you are connecting with ssh or PuTTY ==== Nothing special to do, if you are using [[other:ssh#using_an_x_server_to_display_graphics|"ssh -X" or "ssh -Y"]] or a [[other:putty_conf#changing_some_useful_settings|correctly configured PuTTY]] to connect to a remote Linux server ==== If you are using Windows Subsystem for Linux ==== In that special case, you will need the //X server// to display graphics [[other:x_conf#what_do_we_mean_exactly_with_local_and_remote_computers|from the local virtual machine and from remote computers]] You have to make sure that the ''DISPLAY'' variable is correctly [[other:win10wsl#configuration_in_your_local_linux_account|defined in the terminals used in WSL]] ===== Testing ===== ==== Testing plan ==== The idea is to: * Open a terminal and check that the ''DISPLAY'' environment variable is defined on the local machine * If we use [[other:win10wsl|WSL]], we also check that we can start an application using graphics in ''WSL'' * Connect to the remote machine * Check that a (new) ''DISPLAY'' variable is automatically defined on the remote machine * Check that we can start an application using graphics on the remote machine Test application: * We need a simple graphical application that is likely to be already installed on the remote machine * The **test is declared successful** if we get a new window and we can interact with it.\\ Note: some applications may start with their window iconified, and you may have to check the part of your screen where the iconified windows go... * Do not forget to **cleanly quit the test application** when you have checked that it seems to work * It's enough to test one application * ''xterm &'': the **recommended test application**. It will open a new terminal on the remote machine * ''xeyes &'', ''xclock &'', ''gvim &'', ''gedit &'', ''eog &'', ''evince &'', ... : other //standard// applications, that may be installed (or not) The test may fail, due to the [[other:x_conf#nothing_works|usually expected errors]] ==== On a Linux computer or a Mac ==== Open a //terminal// ([[other:ssh#a_recommended_terminal_for_mac|terminal on a Mac]]) and use some basic commands to check things [Local] $ hostname name_of_your_local_machine [Local] $ echo $DISPLAY :0 [Local] $ ssh -X some_login@some_remote_server [some connection information skipped here] [Remote] $ hostname name_of_the_remote_server [Remote] $ echo $DISPLAY localhost:20.0 [Remote] $ xterm & ==== On a Windows computer with only an X server installed ==== We just open a ''Powershell'' window (''Start'' => ''Windows Powershell'' => ''Windows Powershell'') and type some basic commands, including the creation of a ''DISPLAY'' variable PS C:\> $env:computername name_of_your_local_machine PS C:\> $env:DISPLAY PS C:\> $env:DISPLAY="localhost:0" PS C:\> $env:DISPLAY localhost:0 PS C:\> ssh -Y some_login@some_remote_server Warning: No xauth data; using fake authentication data for X11 forwarding. [some connection information skipped here] [Remote] $ hostname name_of_the_remote_server [Remote] $ echo $DISPLAY localhost:19.0 [Remote] $ xterm & ==== On a Windows computer with PuTTY and an X server installed ==== We assume here that [[other:putty_conf|PuTTY is already installed and configured]] and **correctly** configured (with ''Enable X11 forwarding'') We just have to open a pre-configured //PuTTY Session// on a remote server [Remote] $ hostname name_of_the_remote_server [Remote] $ echo $DISPLAY localhost:19.0 [Remote] $ xterm & ==== On a Windows computer with WSL+Linux and an X server installed ==== We assume that [[other:win10wsl|WSL+Ubuntu]] is installed and that the ''DISPLAY'' variable is [[other:x_conf#if_you_are_using_windows_subsystem_for_linux|configured correctly]] Open a //WSL// terminal (you should know how, if you have installed //WSL//) and type some basic commands [Local WSL] $ hostname name_of_your_local_machine [Local WSL] $ echo $DISPLAY localhost:0.0 [Local WSL] $ xterm & [Local WSL] $ ssh -X some_login@some_remote_server [some connection information skipped here] [Remote] $ echo $DISPLAY localhost:22.0 [Remote] $ xterm & ===== Troubleshooting ===== ==== Nothing works! ==== That's unfortunate, but: * Have you turned on your computer? :-P * Do you have network access, and an account on a remote server? :-? * Have you run the [[other:x_conf#testing|Tests]]? * Have you [[other:x_conf|installed and configured the X server]] correctly? Is it really running? * Have you configured [[other:putty_conf|PuTTY]] and/or other required applications correctly ? * Are you [[other:x_conf#using_x_forwarding_in_a_windows_powershell|using Windows Powershell correctly]]? * Is the [[other:x_conf#what_is_an_x_server|DISPLAY variable]] defined correctly on the local and remote computer? ==== Error when there is no X server running ==== If the ''DISPLAY'' variable is defined, but there is **no X server**, you will get a ''Can't open display: localhost://[SOME VALUE]//'' error $ xterm & xterm: Xt error: Can't open display: localhost:23.0 Time to [[other:x_conf|read this page again]]... ==== Error when there is no space left in your home directory ==== If there is no space left in your home directory (usually the home directory of the remote server), or if you have exceeded your [[other:newppl:starting#which_disks_should_you_use|home disk quota]], you will get an error similar to [[#error_when_there_is_no_x_server_running|Error when there is no X server running]] $ xterm & xterm: Xt error: Can't open display: localhost:23.0 **Solution**: clean the content of your //home//! ==== Error when DISPLAY is not defined correctly ==== If the ''DISPLAY'' **variable is not defined (correctly)**, you will get a ''Can't open display: //[NO VALUE DISPLAYED HERE]//'' error $ xterm & $ xterm: Xt error: Can't open display: xterm: DISPLAY is not set $ echo $DISPLAY $ setenv DISPLAY CRAP_DISPLAY $ xterm xterm: Xt error: Can't open display: CRAP_DISPLAY * Make sure that you are using ''ssh -X'' or ''ssh -Y'', or that [[other:putty_conf#changing_some_useful_settings|PuTTY is configured]] with ''Enable X11 forwarding'' * If you use ''ssh'' in a **Windows Powershell**, read [[other:x_conf#using_x_forwarding_in_a_windows_powershell|Using X forwarding in a Windows Powershell]] ==== Can't start a graphical application by clicking on its desktop shortcut ==== Check the shortcut and run the command directly in a terminal to check the error message There is a good chance that [[other:x_conf#error_when_there_is_no_x_server_running|you have forgotten to start the X server!]] ==== OpenGL related settings ==== It's hard to know what the best //OpenGL// settings for your //X server// are: it depends on your local computer, the remote computer, the network speed, the application generating the graphics, the libraries' versions... * If ''Native opengl'' is activated in ''VcXsrv'', you //may// have to also use the following environment variable on the remote computer: ''export LIBGL_ALWAYS_INDIRECT=1'' * or maybe not! You can try to understand the [[https://unix.stackexchange.com/questions/1437/what-does-libgl-always-indirect-1-actually-do|What does LIBGL_ALWAYS_INDIRECT=1 actually do?]] thread... ==== Blurry display ==== * If you use ''VcXsrv'' and the content of some displayed //X windows// appear **blurry**, see if you can [[other:win10misc#vcxsrv_x_server|fix the compatibility settings]], or try to use **x410**. /* standard page footer */ \\ \\ \\ ---- [ [[pmip3:|PMIP3 Wiki Home]] ] - [ [[pmip3:wiki_help|Help!]] ] - [ [[wiki:syntax|Wiki syntax]] ]