{"id":991,"date":"2024-05-18T21:28:49","date_gmt":"2024-05-18T13:28:49","guid":{"rendered":"https:\/\/www.yiyuanlt.cn\/?p=991"},"modified":"2024-05-18T21:28:49","modified_gmt":"2024-05-18T13:28:49","slug":"%e9%80%82%e7%94%a8%e4%ba%8elinux%e7%9a%84windows%e5%ad%90%e7%b3%bb%e7%bb%9fwsl1%e7%9a%84%e5%ae%89%e8%a3%85%e4%b8%8e%e4%bd%bf%e7%94%a8%e8%ae%b0%e5%bd%95","status":"publish","type":"post","link":"https:\/\/www.yiyuanlt.cn\/index.php\/2024\/05\/18\/%e9%80%82%e7%94%a8%e4%ba%8elinux%e7%9a%84windows%e5%ad%90%e7%b3%bb%e7%bb%9fwsl1%e7%9a%84%e5%ae%89%e8%a3%85%e4%b8%8e%e4%bd%bf%e7%94%a8%e8%ae%b0%e5%bd%95\/","title":{"rendered":"\u9002\u7528\u4e8eLinux\u7684Windows\u5b50\u7cfb\u7edf(WSL1)\u7684\u5b89\u88c5\u4e0e\u4f7f\u7528\u8bb0\u5f55"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Windows Subsystem for Linux (WSL) \u662f\u4e00\u9879\u529f\u80fd\uff0c\u5141\u8bb8\u5728 Windows \u7cfb\u7edf\u4e0a\u8fd0\u884c Linux \u53d1\u884c\u7248\u3002WSL \u63d0\u4f9b\u4e86\u4e00\u4e2a\u4e0e\u4f20\u7edf\u7684 Linux \u73af\u5883\u7c7b\u4f3c\u7684\u64cd\u4f5c\u4f53\u9a8c\uff0c\u4f7f\u5f97\u5728 Windows \u4e0a\u8fdb\u884c\u5f00\u53d1\u548c\u8fd0\u884c Linux \u5e94\u7528\u7a0b\u5e8f\u53d8\u5f97\u66f4\u52a0\u4fbf\u6377\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u672c\u6587\u4ecb\u7ecd\u7684\u662fWSL1\u7684\u5b89\u88c5\u4e8e\u4f7f\u7528\u65b9\u6cd5\uff0c\u7f51\u4e0a\u5927\u591a\u6570\u6587\u7ae0\u90fd\u662f\u5728\u4ecb\u7ecdWSL2\uff0c\u800c\u672c\u4eba\u66f4\u559c\u6b22\u7528WSL1\uff0c\u539f\u56e0\u662fWSL2\u9700\u8981\u5f00\u542f\u201c\u865a\u62df\u673a\u5e73\u53f0\u201d\uff08HyperV\uff09\uff0c\u4f1a\u8ba9PC\u5e73\u65f6\u8fd0\u884c\u7684\u6027\u80fd\u4e0b\u964d\uff0c\u800c\u4e14WSL2\u4e0e\u5b89\u5353\u6a21\u62df\u5668\u3001VMWare\u7b49\u5176\u4ed6\u865a\u62df\u5316\u8f6f\u4ef6\u4e0d\u517c\u5bb9\u3002WSL1\u867d\u7136\u4e0d\u662f\u5b8c\u6574\u5185\u6838\uff0c\u4f46\u662f\u57fa\u672c\u6ee1\u8db3\u5e73\u65f6\u8f6f\u4ef6\u8c03\u8bd5\u7684\u9700\u8981\uff0c\u5982\u679c\u5c11\u6570\u573a\u666f\u4e0d\u6ee1\u8db3\uff0c\u90a3\u5c31\u76f4\u63a5\u4e0aVMWare\u5f00\u865a\u62df\u673a\u5c31\u884c\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u5b89\u88c5WSL<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1\u3001\u63a7\u5236\u9762\u677f-&gt;\u7a0b\u5e8f-&gt;\u542f\u7528\u6216\u5173\u95edWindows\u529f\u80fd\uff0c\u9009\u4e2d\u201c\u9002\u7528\u4e8eLinux\u7684Windows\u5b50\u7cfb\u7edf\u201d\uff0c\u4e0d\u8981\u9009\u201c\u865a\u62df\u673a\u5e73\u53f0\u201c\uff0c\u5b89\u88c5\u540e\u91cd\u542fPC\u3002<br>2\u3001wsl --status \u67e5\u770bWSL\u7248\u672c\uff0c\u5982\u679c\u662f2\uff0c\u5219\u4f7f\u7528wsl --set-default-version 1<br>3\u3001\u5728\u5e94\u7528\u5546\u5e97<a rel=\"noreferrer noopener\" href=\"https:\/\/www.microsoft.com\/store\/productId\/9MTTCL66CPXJ?ocid=pdpshare\" target=\"_blank\" rel=\"nofollow\" >\u5b89\u88c5Ubuntu-20.04<\/a><br>4\u3001\u542f\u52a8Ubuntu-20.04\uff0c\u521d\u59cb\u5316\u5e76\u8bbe\u7f6e\u5bc6\u7801<br><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u8fc1\u79fbWSL<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1\u3001\u67e5\u770b\u5df2\u5b89\u88c5\u7684WSL\u72b6\u6001\uff1awsl -l -v<br>2\u3001\u4e2d\u6b62WSL\u8fd0\u884c\uff1awsl --shutdown<br>3\u3001\u5bfc\u51fa\uff1awsl --export Ubuntu-20.04 D:\\Ubuntu-20.04.tar<br>4\u3001\u6ce8\u9500\u539f\u7cfb\u7edf\uff1awsl --unregister Ubuntu-20.04<br>5\u3001\u5bfc\u5165\uff1awsl --import Ubuntu-20.04 D:\\WSL\\ D:\\Ubuntu-20.04.tar<br>6\u3001\u5220\u9664\u5bfc\u51fa\u7684\u6587\u4ef6\uff1adel D:\\Ubuntu-20.04.tar<br><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u5f00\u542fSSH\u767b\u5f55<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">sudo su<br>sed -i \"s\/^#\\?Port.*\/Port 22\/g\" \/etc\/ssh\/sshd_config;<br>sed -i 's\/^#\\?PermitRootLogin.*\/PermitRootLogin yes\/g' \/etc\/ssh\/sshd_config;<br>sed -i 's\/^#\\?PasswordAuthentication.*\/PasswordAuthentication yes\/g' \/etc\/ssh\/sshd_config;<br>ssh-keygen -t dsa -f \/etc\/ssh\/ssh_host_dsa_key<br>ssh-keygen -t rsa -f \/etc\/ssh\/ssh_host_rsa_key<br>service ssh restart<br>echo \"command=\\\"service ssh start\\\"\" &gt;&gt; \/etc\/wsl.conf<br><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>WSL\u5f00\u673a\u81ea\u542f<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u521b\u5efa\u6587\u4ef6start.vbs\uff0c\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">set ws=wscript.CreateObject(\"wscript.shell\") \nws.run \"wsl -d Ubuntu-20.04\", 0<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5e76\u653e\u5230\u542f\u52a8\u6587\u4ef6\u5939\uff0c\u5c31\u53ef\u4ee5\u5f00\u673a\u81ea\u52a8\u542f\u52a8\u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Windows Subsystem for Linux (WSL) \u662f\u4e00\u9879\u529f\u80fd\uff0c\u5141\u8bb8\u5728 Windows \u7cfb\u7edf\u4e0a\u8fd0\u884c Linux \u53d1 &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-991","post","type-post","status-publish","format-standard","hentry","category-sort"],"_links":{"self":[{"href":"https:\/\/www.yiyuanlt.cn\/index.php\/wp-json\/wp\/v2\/posts\/991","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yiyuanlt.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yiyuanlt.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yiyuanlt.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yiyuanlt.cn\/index.php\/wp-json\/wp\/v2\/comments?post=991"}],"version-history":[{"count":1,"href":"https:\/\/www.yiyuanlt.cn\/index.php\/wp-json\/wp\/v2\/posts\/991\/revisions"}],"predecessor-version":[{"id":992,"href":"https:\/\/www.yiyuanlt.cn\/index.php\/wp-json\/wp\/v2\/posts\/991\/revisions\/992"}],"wp:attachment":[{"href":"https:\/\/www.yiyuanlt.cn\/index.php\/wp-json\/wp\/v2\/media?parent=991"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yiyuanlt.cn\/index.php\/wp-json\/wp\/v2\/categories?post=991"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yiyuanlt.cn\/index.php\/wp-json\/wp\/v2\/tags?post=991"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}