{"id":1865,"date":"2017-11-28T10:43:27","date_gmt":"2017-11-28T18:43:27","guid":{"rendered":"http:\/\/blogs.msdn.microsoft.com\/commandline\/?p=1865"},"modified":"2019-02-25T20:54:10","modified_gmt":"2019-02-26T04:54:10","slug":"a-guide-to-invoking-wsl","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/commandline\/a-guide-to-invoking-wsl\/","title":{"rendered":"A Guide to Invoking WSL"},"content":{"rendered":"<p>There are a variety of ways to invoke the Windows Subsystem for Linux from Windows commandlines and they all behave a little differently. Let\u2019s get to the bottom of it.<\/p>\n<p>\u00a0<\/p>\n<h2><strong>\u00a0\u201cwsl\u201d<\/strong><\/h2>\n<p>The first (and recommended!) method will start up your default distro. Additionally, it starts the distro in the current working directory where you invoke the command. You can change the default distro by using the \u201cwslconfig\u201d tool.<\/p>\n<p>In the example below, we\u2019ll launch into the default distro (Ubuntu) in the current working directory. Then we\u2019ll exit and change our default distro to SUSE.<\/p>\n<p><img decoding=\"async\" width=\"976\" height=\"508\" class=\"alignnone wp-image-1895 size-full\" alt=\"\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/33\/2019\/02\/wsl.gif\" \/><\/p>\n<p>\u00a0<\/p>\n<h2><strong>\u201c<distroname>\u201d<\/strong><\/h2>\n<p>Alternatively, you can specify by name the exact distro you want to launch. We now have several distros in the store and there might be cases where you wish to launch a distro which is not labeled as your default. Using Ubuntu as the example, it\u2019s as simple as calling \u201cubuntu\u201d. This will launch into the distro userland with default shell.<\/p>\n<p><img decoding=\"async\" width=\"976\" height=\"508\" class=\"alignnone wp-image-1885 size-full\" alt=\"\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/33\/2019\/02\/distro.gif\" \/><\/p>\n<p>\u00a0<\/p>\n<h2><strong>\u201cbash\u201d<\/strong><\/h2>\n<p>This will attempt to start bash in your default distro. Even if you\u2019ve configured the distro to have another default shell (take zsh for example), it will still try to launch bash.<\/p>\n<p><img decoding=\"async\" width=\"976\" height=\"508\" class=\"alignnone wp-image-1875 size-full\" alt=\"\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/33\/2019\/02\/bash.gif\" \/><\/p>\n<p>\u00a0<\/p>\n<h2><strong>Executing a Command<\/strong><\/h2>\n<p>For each method, you can append a command that you\u2019d like to execute in the terminal. That is:<\/p>\n<ol>\n<li><distroname> -c [command]<\/li>\n<li>bash -c [command]<\/li>\n<li>wsl &#91;command&#93; (<em>NOTE: In this case you don&#8217;t append &#8216;-c&#8217;, you just type in your command)<\/em><\/li>\n<\/ol>\n<p>You can learn more about multi distro management by <a href=\"https:\/\/msdn.microsoft.com\/en-us\/commandline\/wsl\/wsl-config\">checking out the documentation.<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are a variety of ways to invoke the Windows Subsystem for Linux from Windows commandlines and they all behave a little differently. Let\u2019s get to the bottom of it. \u00a0 \u00a0\u201cwsl\u201d The first (and recommended!) method will start up your default distro. Additionally, it starts the distro in the current working directory where you [&hellip;]<\/p>\n","protected":false},"author":1035,"featured_media":4522,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[2,3,9],"tags":[22,29,42,72],"class_list":["post-1865","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-command-line","category-linux-tools","category-bash-on-ubuntu-on-windows","tag-bash","tag-command-line","tag-linux","tag-wsl"],"acf":[],"blog_post_summary":"<p>There are a variety of ways to invoke the Windows Subsystem for Linux from Windows commandlines and they all behave a little differently. Let\u2019s get to the bottom of it. \u00a0 \u00a0\u201cwsl\u201d The first (and recommended!) method will start up your default distro. Additionally, it starts the distro in the current working directory where you [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/commandline\/wp-json\/wp\/v2\/posts\/1865","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/commandline\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/commandline\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/commandline\/wp-json\/wp\/v2\/users\/1035"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/commandline\/wp-json\/wp\/v2\/comments?post=1865"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/commandline\/wp-json\/wp\/v2\/posts\/1865\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/commandline\/wp-json\/wp\/v2\/media\/4522"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/commandline\/wp-json\/wp\/v2\/media?parent=1865"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/commandline\/wp-json\/wp\/v2\/categories?post=1865"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/commandline\/wp-json\/wp\/v2\/tags?post=1865"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}