mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-23 21:20:42 +08:00
translated
This commit is contained in:
parent
f1fa489c0f
commit
3d83918007
@ -1,153 +0,0 @@
|
|||||||
[#]: subject: "Shut Down WSL Running Linux Distributions"
|
|
||||||
[#]: via: "https://itsfoss.com/shut-down-wsl-distros/"
|
|
||||||
[#]: author: "Sreenath https://itsfoss.com/author/sreenath/"
|
|
||||||
[#]: collector: "lujun9972/lctt-scripts-1705972010"
|
|
||||||
[#]: translator: "geekpi"
|
|
||||||
[#]: reviewer: " "
|
|
||||||
[#]: publisher: " "
|
|
||||||
[#]: url: " "
|
|
||||||
|
|
||||||
Shut Down WSL Running Linux Distributions
|
|
||||||
======
|
|
||||||
|
|
||||||
So you are running Linux inside Windows using WSL. And you are wondering how you can shut down the Linux distribution running in WSL.
|
|
||||||
|
|
||||||
You can surely [try the shutdown command][1] from within the Linux system running in WSL:
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
sudo shutdown now
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
You can also shut down Linux systems using WSL commands. It's an excellent method if you have more than one distro running is WSL.
|
|
||||||
|
|
||||||
### Shutdown Linux in WSL using Windows Terminal
|
|
||||||
|
|
||||||
In this method, I assume that the usual `shutdown` command doesn't work in WSL Linux Systems.
|
|
||||||
|
|
||||||
First, open a terminal in windows. Here, I am using Windows 11 with an Ubuntu setup under WSL 2.
|
|
||||||
|
|
||||||
![Open a Windows Terminal][2]
|
|
||||||
|
|
||||||
💡
|
|
||||||
|
|
||||||
You can use the wsl command on a standard Windows terminal. The command is also accessible inside a running Linux distribution. Here, the name of the command is wsl.exe.
|
|
||||||
|
|
||||||
Now, you need to list what distros are installed and what are their status. To do this, enter:
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
wsl --list --verbose
|
|
||||||
|
|
||||||
OR
|
|
||||||
|
|
||||||
wsl -l -v
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
![List Installed Distributions][3]
|
|
||||||
|
|
||||||
Here, you can see that, I have one installed WSL Ubuntu, which is currently running.
|
|
||||||
|
|
||||||
#### Shutdown all running Linux distributions
|
|
||||||
|
|
||||||
There may be times, when you want to stop app the running WSL instances in one go.
|
|
||||||
|
|
||||||
In Powershell or Windows Terminal, use this command:
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
wsl --shutdown
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
This will shut down all sessions.
|
|
||||||
|
|
||||||
Also, you can **perform the same function inside any running WSL Linux Distribution terminal**. You just need to use `wsl.exe` instead of `wsl`, while working inside a distribution.
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
wsl.exe --shutdown
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
![Shut Down All Running WSL Distributions][4]
|
|
||||||
|
|
||||||
Once you run this command, all the running WSL distributions will be terminated. The WSL 2 lightweight utility virtual machine is also terminated. **So it will be useful, if you want to restart the WSL 2 virtual machine environment.**
|
|
||||||
|
|
||||||
#### Terminate a particular Linux distribution
|
|
||||||
|
|
||||||
To terminate a particular running WSL distribution, open a separate Windows terminal and run:
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
wsl --terminate <Distribution Name>
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
Here, the distribution name is the one you get, when you list all the installed WSL distributions using the `wsl -l -v` command.
|
|
||||||
|
|
||||||
![List WSL Distributions][5]
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
wsl --terminate Ubuntu
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
Once executed, the specified Linux distribution will be terminated.
|
|
||||||
|
|
||||||
If you are inside another distribution, list all the WSL distros installed on your system using:
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
wsl.exe -l -v
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
Now, terminate the required distro using:
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
wsl.exe --terminate <Distribution name>
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
![Shutting down a WSL Distribution from inside another][6]
|
|
||||||
|
|
||||||
### Conclusion
|
|
||||||
|
|
||||||
Some people just close the running Linux application but I don't think that's very graceful.
|
|
||||||
|
|
||||||
Also, like a Linux terminal, you can either use:
|
|
||||||
|
|
||||||
* The `logout` command, to close that distro.
|
|
||||||
* The `exit` command to quit that terminal running the Linux distro.
|
|
||||||
* Or, press CTRL+D to do the same as exit command.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
But the WSL way of shutting down Linux system has the added advantage of doing it for multiple Linux systems.
|
|
||||||
|
|
||||||
I hope it helps you.
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
via: https://itsfoss.com/shut-down-wsl-distros/
|
|
||||||
|
|
||||||
作者:[Sreenath][a]
|
|
||||||
选题:[lujun9972][b]
|
|
||||||
译者:[译者ID](https://github.com/译者ID)
|
|
||||||
校对:[校对者ID](https://github.com/校对者ID)
|
|
||||||
|
|
||||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
|
||||||
|
|
||||||
[a]: https://itsfoss.com/author/sreenath/
|
|
||||||
[b]: https://github.com/lujun9972
|
|
||||||
[1]: https://linuxhandbook.com/linux-shutdown-command/
|
|
||||||
[2]: https://itsfoss.com/content/images/2024/01/open-a-terminal-from-start-menu.png
|
|
||||||
[3]: https://itsfoss.com/content/images/2024/01/list-installed-distributions-and-their-status.png
|
|
||||||
[4]: https://itsfoss.com/content/images/2024/01/shutdown-all-wsl-distros-within-another-distro.gif
|
|
||||||
[5]: https://itsfoss.com/content/images/2024/01/list-the-distro-to-terminate-only-that-one.png
|
|
||||||
[6]: https://itsfoss.com/content/images/2024/01/shutdown-successfully-completed.png
|
|
@ -0,0 +1,153 @@
|
|||||||
|
[#]: subject: "Shut Down WSL Running Linux Distributions"
|
||||||
|
[#]: via: "https://itsfoss.com/shut-down-wsl-distros/"
|
||||||
|
[#]: author: "Sreenath https://itsfoss.com/author/sreenath/"
|
||||||
|
[#]: collector: "lujun9972/lctt-scripts-1705972010"
|
||||||
|
[#]: translator: "geekpi"
|
||||||
|
[#]: reviewer: " "
|
||||||
|
[#]: publisher: " "
|
||||||
|
[#]: url: " "
|
||||||
|
|
||||||
|
关闭 WSL 中正在运行的 Linux 发行版。
|
||||||
|
======
|
||||||
|
|
||||||
|
你使用 WSL 在 Windows 内运行 Linux。你想知道如何关闭在 WSL 中运行的 Linux 发行版。
|
||||||
|
|
||||||
|
你当然可以在 WSL 中运行的 Linux 系统中[尝试关闭命令][1]:
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
sudo shutdown now
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
你还可以使用 WSL 命令关闭 Linux 系统。如果你有多个发行版在 WSL 中运行,这是一种极好的方法。
|
||||||
|
|
||||||
|
### 在 WSL 中使用 Windows 终端关闭 Linux 系统
|
||||||
|
|
||||||
|
在这个方法中,我假设通常的 `shutdown` 命令在 WSL Linux 系统中不起作用。
|
||||||
|
|
||||||
|
首先,在 Windows 中打开一个终端。在这里,我使用的是 Windows 11,并在 WSL 2 下安装了 Ubuntu。
|
||||||
|
|
||||||
|
![打开 Windows 终端][2]
|
||||||
|
|
||||||
|
💡
|
||||||
|
|
||||||
|
你可以在标准的 Windows 终端上使用 wsl 命令。在运行的 Linux 发行版中也可以访问该命令。这里,命令的名称是 wsl.exe。
|
||||||
|
|
||||||
|
现在,你需要列出已安装的发行版及其状态。为此,请输入
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
wsl --list --verbose
|
||||||
|
|
||||||
|
或
|
||||||
|
|
||||||
|
wsl -l -v
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
![列出已安装的发行版][3]
|
||||||
|
|
||||||
|
在这里,你可以看到,我已经安装了一个 WSL Ubuntu,它目前正在运行。
|
||||||
|
|
||||||
|
#### 关闭所有正在运行的 Linux 发行版
|
||||||
|
|
||||||
|
有时,你可能想一次性停止正在运行的 WSL 实例。
|
||||||
|
|
||||||
|
在 Powershell 或 Windows 终端中,使用以下命令:
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
wsl --shutdown
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
这将关闭所有会话。
|
||||||
|
|
||||||
|
此外,你还可以**在任何正在运行的 WSL Linux 发行版终端中执行相同的功能**。在发行版中时,你只需要使用 `wsl.exe` 而不是 `wsl`。
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
wsl.exe --shutdown
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
![关闭所有正在运行的 WSL 发行版][4]
|
||||||
|
|
||||||
|
运行此命令后,所有正在运行的 WSL 发行版都将终止。WSL 2 轻量级虚拟机也被终止。**因此,如果你想重新启动 WSL 2 虚拟机环境,它将很有用。**
|
||||||
|
|
||||||
|
#### 终止特定的 Linux 发行版
|
||||||
|
|
||||||
|
要终止特定正在运行的 WSL 发行版,请打开单独的 Windows 终端并运行:
|
||||||
|
|
||||||
|
````
|
||||||
|
|
||||||
|
wsl --terminate <发行版名称>
|
||||||
|
|
||||||
|
````
|
||||||
|
|
||||||
|
此处,发行版名称是你使用 `wsl -l -v` 命令列出所有已安装的 WSL 发行版时获得的名称。
|
||||||
|
|
||||||
|
![列出 WSL 发行版][5]
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
wsl --terminate Ubuntu
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
执行后,指定的 Linux 发行版将被终止。
|
||||||
|
|
||||||
|
如果你在另一个发行版中,请使用以下命令列出系统上安装的所有 WSL 发行版:
|
||||||
|
|
||||||
|
````
|
||||||
|
|
||||||
|
wsl.exe -l -v
|
||||||
|
|
||||||
|
````
|
||||||
|
|
||||||
|
现在,使用以下命令终止所需的发行版:
|
||||||
|
|
||||||
|
````
|
||||||
|
|
||||||
|
wsl.exe --terminate <发行版名称>
|
||||||
|
|
||||||
|
````
|
||||||
|
|
||||||
|
![从另一个 WSL 分发版中关闭 WSL 分发版][6]
|
||||||
|
|
||||||
|
### 结论
|
||||||
|
|
||||||
|
有些人只是关闭正在运行的 Linux 应用,但我认为这不太优雅。
|
||||||
|
|
||||||
|
另外,就像 Linux 终端一样,你可以使用:
|
||||||
|
|
||||||
|
* `logout` 命令,用于关闭该发行版。
|
||||||
|
* `exit` 命令用于退出运行 Linux 发行版的终端。
|
||||||
|
* 或者,按 CTRL+D 执行与 exit 命令相同的操作。
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
但关闭 Linux 系统的 WSL 方式还有一个额外的优势,即可以针对多个 Linux 系统执行此操作。
|
||||||
|
|
||||||
|
我希望它对你有帮助。
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
via: https://itsfoss.com/shut-down-wsl-distros/
|
||||||
|
|
||||||
|
作者:[Sreenath][a]
|
||||||
|
选题:[lujun9972][b]
|
||||||
|
译者:[geekpi](https://github.com/geekpi)
|
||||||
|
校对:[校对者ID](https://github.com/校对者ID)
|
||||||
|
|
||||||
|
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||||
|
|
||||||
|
[a]: https://itsfoss.com/author/sreenath/
|
||||||
|
[b]: https://github.com/lujun9972
|
||||||
|
[1]: https://linuxhandbook.com/linux-shutdown-command/
|
||||||
|
[2]: https://itsfoss.com/content/images/2024/01/open-a-terminal-from-start-menu.png
|
||||||
|
[3]: https://itsfoss.com/content/images/2024/01/list-installed-distributions-and-their-status.png
|
||||||
|
[4]: https://itsfoss.com/content/images/2024/01/shutdown-all-wsl-distros-within-another-distro.gif
|
||||||
|
[5]: https://itsfoss.com/content/images/2024/01/list-the-distro-to-terminate-only-that-one.png
|
||||||
|
[6]: https://itsfoss.com/content/images/2024/01/shutdown-successfully-completed.png
|
Loading…
Reference in New Issue
Block a user