clone url: git://


1 <!DOCTYPE html>
2 <html xmlns="" lang="en" xml:lang="en">
3 <head>
4 <meta charset="utf-8" />
5 <meta name="generator" content="pandoc" />
6 <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
7 <title>Setting up graphical applications in Windows Subsystem for Linux</title>
8 <style>
9 code{white-space: pre-wrap;}
10 span.smallcaps{font-variant: small-caps;}
11 span.underline{text-decoration: underline;}
12 div.column{display: inline-block; vertical-align: top; width: 50%;}
13 div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
14 ul.task-list{list-style: none;}
15 </style>
16 <link rel="stylesheet" href="/assets/archive.css">
17 </head>
18 <body>
19 <main>
20 <h2 id="setting-up-graphical-applications-in-windows-subsystem-for-linux">Setting up graphical applications in Windows Subsystem for Linux</h2>
21 <p>2019-12-03 00:00</p>
22 <p>This guide will teach you how to access graphical applications from Microsoft’s Windows Subsystem for Linux. This guide is intended for people who are familiar with editing files using command line tools.</p>
23 <p>This guide consists of the following sections:</p>
24 <ul>
25 <li><a href="#conventions-used-in-this-guide">Conventions used in this guide</a></li>
26 <li><a href="#requirements">Requirements</a></li>
27 <li><a href="#preparing-windows-subsystem-for-linux">Preparing Windows Subsystem for Linux</a></li>
28 <li><a href="#enabling-xming-on-startup">Enabling Xming on startup</a></li>
29 <li><a href="#creating-a-windows-desktop-shortcut-to-a-windows-subsystem-for-linux-graphical-application">Creating a Windows desktop shortcut to a Windows Subsystem for Linux graphical application</a></li>
30 <li><a href="#navigating-to-your-windows-home-directory-from-windows-subsystem-for-linux">Navigating to your Windows home directory from Windows Subsystem for Linux</a></li>
31 </ul>
32 <h3 id="conventions-used-in-this-guide">Conventions used in this guide</h3>
33 <ul>
34 <li><strong>Note</strong>: Signifies additional information</li>
35 <li><strong>Tip</strong>: Signifies an alternative procedure for completing a step</li>
36 <li><strong>Warning</strong>: Signifies that damage, such as data loss, may occur</li>
37 <li><strong>Example</strong>: Shows how a procedure would be performed in a real scenario</li>
38 <li><code>Inline code and code blocks</code>: Signify package names, filenames, file contents, or commands</li>
39 <li><code>&lt;variable&gt;</code> Signifies that the text between the <code>&lt;</code> and <code>&gt;</code> should be replaced, and the <code>&lt;</code> and <code>&gt;</code> should be removed</li>
40 <li><strong>Bold font</strong> Signifies user interface items</li>
41 </ul>
42 <h3 id="requirements">Requirements</h3>
43 <ul>
44 <li>Windows 10 or above</li>
45 <li>Windows Subsystem for Linux</li>
46 <li>A Linux distribution to use on Windows Subsystem for Linux</li>
47 </ul>
48 <aside class="border">
49 <p>
50 <strong>Note</strong>: If you have Windows 10 or above, but have not installed Windows Subsystem for Linux or a Linux distribution for Windows Subsystem for Linux, <a href="">Microsoft’s website</a> provides instructions on how to do this.
51 </p>
52 </aside>
53 <h3 id="preparing-windows-subsystem-for-linux">Preparing Windows Subsystem for Linux</h3>
54 <p>The preparations in this section will prevent settings and file permissions from resetting when you close a terminal window, create a place for graphical applications to run, and prepare your command line configuration files for handling calls to graphical applications.</p>
55 <h4 id="to-prepare-windows-subsystem-for-linux">To prepare Windows Subsystem for Linux</h4>
56 <ol type="1">
57 <li><p>Allow Linux and Microsoft Windows to retain separate file permissions when using <code>chmod</code> in Windows Subsystem for Linux by adding the following contents to <code>/etc/wsl.conf</code>:</p>
58 <pre><code> [automount]
59 options = &quot;metadata&quot;</code></pre></li>
60 <li><p>Download Xming <a href="">here</a></p></li>
61 <li><p>Install Xming</p></li>
62 <li><p>Add the following contents to <code>.bashrc</code>:</p>
63 <pre><code> export DISPLAY=:0</code></pre></li>
64 <li><p>Install the graphical packages you want to use by running the following command:</p>
65 <pre><code> sudo apt install</code></pre></li>
66 </ol>
67 <aside class="border">
68 <p>
69 <strong>Note</strong>: In Step 1 above, ensure you are editing <code>/etc/wsl.conf</code> with root permissions using <code>sudo</code> or <code>su</code>.
70 </p>
71 </aside>
72 <aside class="border">
73 <p>
74 <strong>Example</strong>: In Step 5 above, to install the <code>xfce4-terminal</code> package, you would run the following command:
75 </p>
76 <pre>
77 sudo apt install xfce4-terminal
78 </pre>
79 </aside>
80 <h3 id="enabling-xming-on-startup">Enabling Xming on startup</h3>
81 <p>The instructions in this section will help you enable Xming everytime Microsoft Windows starts. This will remove the need to manually start the Xming application everytime you start your computer.</p>
82 <h4 id="to-enable-xming-on-startup">To enable Xming on startup</h4>
83 <ol type="1">
84 <li><p>Navigate to the following directory in Microsoft Windows:</p>
85 <pre><code> C:\Users\USERNAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup</code></pre></li>
86 <li><p>Right-click on an empty space</p></li>
87 <li><p>Click <strong>New</strong> &gt; <strong>Shortcut</strong></p></li>
88 <li><p>Under <strong>Type the location of the item:</strong>, enter the following value:</p>
89 <pre><code> &quot;C:\Program Files (x86)\Xming\Xming.exe&quot;</code></pre></li>
90 <li><p>Click <strong>Next</strong></p></li>
91 <li><p>Right-click the new shortcut</p></li>
92 <li><p>Beside <strong>Target:</strong>, enter the following value:</p>
93 <pre><code> &quot;C:\Program Files (x86)\Xming\Xming.exe&quot; :0 -clipboard -multiwindow</code></pre></li>
94 <li><p>Ensure the value beside <strong>Start in:</strong> is the following value:</p>
95 <pre><code> &quot;C:\Program Files (x86)\Xming&quot;</code></pre></li>
96 </ol>
97 <aside class="border">
98 <p>
99 <strong>Note 1</strong>: In Step 1 above, you will have to replace <code>USERNAME</code> with your Microsoft Windows username.
100 </p>
101 <aside class="border">
102 <p>
103 <strong>Example</strong>: My Microsoft Windows username is Jesse, so I would change the line:
104 </p>
105 <pre>
106 C:\Users\USERNAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
107 </pre>
108 <p>
109 to
110 </p>
111 <pre>
112 C:\Users\Jesse\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
113 </pre>
114 </aside>
115 </aside>
116 <aside class="border">
117 <p>
118 <strong>Note 2</strong>: In Steps 4 and 8 above, you may have to alter the path to Xming, depending on where you installed it.
119 </p>
120 </aside>
121 <h3 id="creating-a-windows-desktop-shortcut-to-a-windows-subsystem-for-linux-graphical-application">Creating a Windows desktop shortcut to a Windows Subsystem for Linux graphical application</h3>
122 <p>The instructions in this section will help you create a Microsoft Windows desktop shortcut. Shortcuts to graphical applications will remove the need to open a terminal emulator every time you want to open a graphical application.</p>
123 <aside class="border">
124 <p>
125 <strong>Note</strong>: In the steps below, we will use the <code>xfce4-terminal</code> application as an example.
126 </p>
127 </aside>
128 <h4 id="to-create-a-windows-desktop-shortcut-to-a-windows-subsystem-for-linux-graphical-application">To create a Windows desktop shortcut to a Windows Subsystem for Linux graphical application</h4>
129 <ol type="1">
130 <li><p>Right-click the desktop</p></li>
131 <li><p>Click <strong>New… &gt; Shortcut</strong></p></li>
132 <li><p>Under <strong>Type the location of the item</strong>, enter the following value:</p>
133 <pre><code> powershell -windowstyle hidden -Command &quot;iex &quot;bash ~ -c &#39;DISPLAY=:0 xfce4-terminal&#39;&quot; &quot;</code></pre></li>
134 </ol>
135 <h3 id="navigating-to-your-windows-home-directory-from-windows-subsystem-for-linux">Navigating to your Windows home directory from Windows Subsystem for Linux</h3>
136 <p>This section will guide you through creating command line shortcuts called <a href="">symlinks</a>. This will help you access Microsoft Windows files and directories without having to type <code>/mnt/c/Users/USERNAME/</code> before every Microsoft Windows path.</p>
137 <h4 id="to-navigate-to-your-microsoft-windows-home-directory-for-windows-subsystem-for-linux">To navigate to your Microsoft Windows home directory for Windows Subsystem for Linux</h4>
138 <ol type="1">
139 <li><p>Navigate to the directory in which you want the symlink to exist using <code>cd /path/to/a/directory</code></p></li>
140 <li><p>Run the following command:</p>
141 <pre><code> ln -s /mnt/c/Users/USERNAME/PATH/TO/DIRECTORY/ ~/path/to/your/shortcut</code></pre></li>
142 </ol>
143 <aside class="border">
144 <p>
145 <strong>Example</strong>: If a user with the Microsoft Windows username “Sarah” wanted to create a symlink from Windows Subsystem for Linux to Sarah’s Documents directory in Microsoft Windows, they would run:
146 </p>
147 <pre>
148 ln -s /mnt/c/Users/Sarah/Documents/ ~/doc
149 </pre>
150 </aside>
151 <p>In this example, Sarah can now access their Microsoft Windows Documents directory by typing <code>cd doc</code> from their Windows Subsystem for Linux home directory, instead of typing out <code>cd /mnt/c/Users/Sarah/Documents</code> every time.</p>
152 </main>
153 </body>
154 </html>