{"id":40761,"date":"2023-10-03T21:27:47","date_gmt":"2023-10-03T21:27:47","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=40761"},"modified":"2024-05-29T15:24:02","modified_gmt":"2024-05-29T15:24:02","slug":"list-of-commands-for-wsl","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/list-of-commands-for-wsl\/","title":{"rendered":"List of commands for wsl"},"content":{"rendered":"\n<p>Windows Subsystem for Linux (WSL) allows you to run a Linux distribution directly on Windows without the overhead of a traditional virtual machine or dual-boot setup. Here are some commonly used commands and operations related to WSL:<\/p>\n\n\n\n<p>You guys might learn these commands in your Computer Science course. While studying CS coursework you might consider expert <a href=\"https:\/\/codingzap.com\/do-my-computer-science-homework\/\" target=\"_blank\" rel=\"noopener\">help in CS HW<\/a><\/p>\n\n\n\n<p>Here is a list of some of the most common WSL commands:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>wsl<\/code>: This command will start a new WSL session.<\/li>\n\n\n\n<li><code>wsl -l<\/code>: This command will list all of the installed WSL distributions.<\/li>\n\n\n\n<li><code>wsl -d &lt;distribution name&gt;<\/code>: This command will start a new WSL session using the specified distribution.<\/li>\n\n\n\n<li><code>wsl --shutdown<\/code>: This command will shut down all running WSL sessions.<\/li>\n\n\n\n<li><code>wsl --terminate &lt;distribution name&gt;<\/code>: This command will terminate the WSL session for the specified distribution.<\/li>\n\n\n\n<li><code>wsl --set-version &lt;version number&gt;<\/code>: This command will set the default WSL version.<\/li>\n\n\n\n<li><code>wsl --status<\/code>: This command will display the status of all running WSL sessions.<\/li>\n\n\n\n<li><code>wsl --import &lt;distribution name&gt; &lt;tarball path&gt;<\/code>: This command will import a new WSL distribution from a tarball file.<\/li>\n\n\n\n<li><code>wsl --export &lt;distribution name&gt; &lt;export path&gt;<\/code>: This command will export a WSL distribution to a tarball file.<\/li>\n\n\n\n<li><code>wsl --mount &lt;source path&gt; &lt;mount point&gt;<\/code>: This command will mount a Windows file system path to a WSL mount point.<\/li>\n\n\n\n<li><code>wsl --unmount &lt;mount point&gt;<\/code>: This command will unmount a WSL mount point.<\/li>\n\n\n\n<li><code>wsl --default &lt;distribution name&gt;<\/code>: This command will set the default WSL distribution.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">WSL Management Commands<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>List installed WSL distributions<\/strong>:<code>wsl --list or wsl -l<\/code><\/li>\n\n\n\n<li><strong>List all distributions, including those that aren&#8217;t currently installed<\/strong>:<code>wsl --list --all or wsl -l -a<\/code><\/li>\n\n\n\n<li><strong>Set a default distribution<\/strong> (this is the distribution that will be used if you just type <code>wsl<\/code> into the command prompt):<code>wsl --setdefault &lt;DistributionName&gt;<\/code><\/li>\n\n\n\n<li><strong>Set version of WSL for a distribution<\/strong> (WSL 1 or WSL 2):<code>wsl --set-version &lt;DistributionName&gt; &lt;VersionNumber&gt;<\/code><\/li>\n\n\n\n<li><strong>Terminate a running WSL distribution<\/strong>:<code>wsl --terminate &lt;DistributionName&gt;<\/code><\/li>\n\n\n\n<li><strong>Shutdown all running WSL instances<\/strong>:<code>wsl --shutdown<\/code><\/li>\n\n\n\n<li><strong>Install a new distribution<\/strong> (this command will install the distribution but allow you to set up a new user, etc., later):<code>wsl --install -d &lt;DistributionName&gt;<\/code><\/li>\n\n\n\n<li><strong>Unregister and remove a distribution<\/strong> (WARNING: This will remove the Linux distribution from WSL and also delete the user account and data): <code>wsl --unregister &lt;DistributionName&gt;<\/code><\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">General WSL Commands<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Open a new WSL terminal window<\/strong>: Simply type <code>wsl<\/code> into the command prompt or PowerShell.<\/li>\n\n\n\n<li><strong>Run a Linux command without entering the WSL terminal<\/strong>:<code>wsl &lt;LinuxCommand&gt; <\/code>For example, to list files in the Linux home directory:<code>wsl ls -la ~<\/code><\/li>\n\n\n\n<li><strong>Access Windows files from WSL<\/strong>: In WSL, your Windows drives are mounted under the <code>\/mnt<\/code> directory. So, for example, your C drive would be available at <code>\/mnt\/c\/<\/code>. <code>cd \/mnt\/c\/Users\/&lt;YourWindowsUsername&gt;\/<\/code><\/li>\n\n\n\n<li><strong>Access WSL files from Windows<\/strong>: For WSL 2, you can access the Linux file system by navigating to <code>\\\\wsl$\\&lt;DistributionName&gt;<\/code> in File Explorer.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Configuration<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Edit WSL settings<\/strong>: WSL configurations can be modified by editing the file: <code>C:\\Users\\&lt;YourWindowsUsername&gt;\\.wslconfig<\/code><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Windows Subsystem for Linux (WSL) allows you to run a Linux distribution directly on Windows without the overhead of a traditional virtual machine or dual-boot setup. Here are some commonly&#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[2],"tags":[],"class_list":["post-40761","post","type-post","status-publish","format-standard","hentry","category-uncategorised"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/40761","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=40761"}],"version-history":[{"count":3,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/40761\/revisions"}],"predecessor-version":[{"id":46365,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/40761\/revisions\/46365"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=40761"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=40761"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=40761"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}