可以在 Windows 10 PC 上安装和使用Linux Bash shell 。这是一个在您的 PC 上运行的Linux子系统,无需在虚拟机上安装 Linux(installing Linux on a virtual machine)。
使用Windows 10(Windows 10)上的这个Linux Bash shell ,您可以在 Windows PC 上运行各种Linux命令和应用程序(不是图形应用程序)。此外,您可以选择安装自己喜欢的Linux发行版,包括Ubuntu。
在本指南中,我们将重点介绍在Windows 10上安装 Linux 的(Windows 10)Ubuntu发行版。
第 1 步:在 Windows 功能中启用 Linux(Step 1: Enable Linux in Windows Features)
执行的第一步是在您的 Windows 10 PC 上启用并安装适用于Linux的(Linux)Windows 子系统。(Windows Subsystem)您可以从Windows 功能(Windows Features)面板执行此操作。
此选项仅适用于 64 位版本的Windows 10。在继续之前检查您的 PC 运行的位版本(what bit version your PC runs)。
如果您的 PC 运行 64 位版本的Windows 10,请按照以下步骤操作:
- 在您的 PC 上打开控制面板(Open Control Panel on your PC)。
- 在主控制面板窗口中选择程序。(Programs)
- 在以下屏幕上,从“程序和功能(Programs and Features)”部分中选择“打开或关闭 Windows 功能” 。(Turn Windows features on or off)
- 在打开的Windows 功能(Windows Features)窗口中,向下滚动并启用适用于 Linux 的 Windows 子系统(Windows Subsystem for Linux)选项。
- 选择窗口底部的确定(OK)以保存更改。
- Windows 将要求您重新启动计算机以使更改生效。选择立即重新启动(Restart now)以重新启动您的 PC。
第 2 步:在您的 PC 上下载并安装 Linux 发行版(Step 2: Download and Install a Linux Distribution on Your PC)
现在已安装适用于Linux的 Windows(Linux)子系统(Subsystem),请下载您喜欢的Linux发行版并将其安装在您的 PC 上。您可以在Microsoft Store(Microsoft Store)上安装多个Linux发行版。
我们将按照以下步骤安装Ubuntu发行版。(Ubuntu)
- 当您的 PC 在上述部分的最后一步后重新启动时,打开“开始(Start)”菜单,搜索Microsoft Store ,然后在搜索结果中选择Microsoft Store 。
- 在Store中,选择右上角的Search并输入(Search)Ubuntu。如果需要,您可以在此处输入任何其他Linux发行版名称。(Linux)
- 在搜索结果中选择Ubuntu 。
- 在 Ubuntu 的应用程序屏幕上,选择安装(Install)以在您的 PC 上安装此Linux发行版。(Linux)Windows将安装此发行版,就像您正在安装任何其他应用商店(Store)应用一样。
- 安装Ubuntu 后(Ubuntu)关闭Microsoft Store 。
第 3 步:在 Windows 10 上配置 Linux Bash Shell(Step 3: Configure the Linux Bash Shell on Windows 10)
Linux Bash shell现在已安装在您的 PC 上,您可以开始使用它了。
当您第一次运行 shell 时,它会要求您配置一些选项。以下是启动和配置 shell 的方法:
- 打开开始(Start)菜单,搜索Ubuntu ,然后在搜索结果中选择Ubuntu 。
- 当Ubuntu打开时,它会开始自动配置它的一些选项。等待这个完成。
- 当您看到输入新的 UNIX 用户名(Enter new UNIX username)提示时,输入您希望用于Bash shell 的用户名。此用户名可能与您在Windows用户帐户中使用的用户名不同。然后,按Enter。
- 然后Ubuntu(Ubuntu)会要求您为 shell 创建一个密码。输入密码并按Enter。
- 再次输入密码并按Enter。
- 该窗口将显示各种消息。在这些消息的底部,您将看到您刚刚创建的用户名和您的 PC 名称。
- 您现在可以开始在您的 PC 上运行Linux命令。(Linux)
第 4 步:开始在 Windows 10 上使用 Linux Bash Shell 命令(Step 4: Start Using Linux Bash Shell Commands on Windows 10)
Linux Bash shell现在已完全配置,您可以开始在其中运行命令(start running your commands)。如果您不确定从什么命令开始,以下将为您提供一些想法。
请注意,以sudo开头的每个命令都要求您输入在上一节中创建的密码。这是因为这些命令需要管理员权限才能运行。
1.更新包列表(1. Update Package List)
命令:(Command:) sudo apt-get update
此命令会更新特定Linux发行版的软件包列表。请记住,此命令实际上并不安装任何更新;它只更新列表。
2. 安装软件更新(2. Install Software Updates)
命令:(Command:) sudo apt-get upgrade
使用此命令获取安装在Linux发行版上的应用程序的更新。
3.安装新程序(3. Install a New Program)
命令:(Command:) sudo apt-get install PackageName
此命令可帮助您在 Linux 发行版上安装程序(install a program on your Linux)。将命令中的PackageName(PackageName)替换为您要安装的程序的名称。
例如,要安装Audacity,您将使用以下命令:
sudo apt-get install audacity
4.删除已安装的程序(4. Remove an Installed Program)
命令:(Command:) sudo apt-get remove PackageName
要从Linux发行版中删除程序,请使用此命令将PackageName替换为要删除的程序的名称。
5. 编辑文本文件(5. Edit a Text File)
命令:(Command:) 纳米文件名.txt(nano FileName.txt)
此命令打开 Ubuntu 的内置文本编辑器,让您编辑指定的文件。确保(Make)将FileName替换为您要编辑的文件的实际名称。
6.列出目录的内容(6. List the Contents of a Directory)
命令:(Command:) ls(这是一个小L)
使用此命令显示当前工作目录的内容。
7.更改当前目录(7. Change the Current Directory)
命令:(Command:) cd 路径(cd Path)
要更改当前工作目录,请运行此命令,将Path替换为要创建新工作目录的目录的完整路径。
8. 从 Internet 下载文件(8. Download Files From the Internet)
命令:(Command:) wget URL
您可以使用此命令将文件从 Internet 下载到您的计算机。只需将命令中的(Simply)URL替换为您要下载的文件的网址即可。
9.清除终端屏幕(9. Clear the Terminal Screen)
命令:(Command:) 清除(clear)
此命令会清除终端(Terminal)窗口中的所有内容,并让您从头开始输入命令。当您的终端(Terminal)屏幕太杂乱时使用此选项。
10. 退出终端(10. Quit the Terminal)
命令:(Command:) 退出(exit)
此命令关闭终端(Terminal)窗口。当您完成使用命令时使用它。
这些是您在 Windows 10 PC 上开始使用Linux Bash shell 时(Linux Bash)应该学习的一些基本命令。(commands you should learn)我们希望本指南对您有所帮助。
How to Use Linux Bash Shell on Windows 10
It’s possible to install and use the Linux Bash shell on your Windows 10 PC. This is a Linux subsystem that runs on your PC without installing Linux on a virtual machine.
With this Linux Bash shell on Windows 10, you can run various Linux commands and apps (not the graphical ones) on your Windows PC. Also, you have the option to install your favorite Linux distribution, including Ubuntu.
In this guide, we’ll focus on installing Linux’s Ubuntu distribution on Windows 10.
Step 1: Enable Linux in Windows Features
The first step to perform is to enable and install Windows Subsystem for Linux on your Windows 10 PC. You can do this from the Windows Features panel.
This option only works for the 64-bit versions of Windows 10. Check what bit version your PC runs before you proceed.
If your PC runs the 64-bit version of Windows 10, follow these steps:
- Open Control Panel on your PC.
- Select Programs on the main Control Panel window.
- On the following screen, select Turn Windows features on or off from the Programs and Features section.
- In the Windows Features window that opens, scroll down and enable the Windows Subsystem for Linux option.
- Select OK at the bottom of the window to save your changes.
- Windows will ask you to reboot your computer to bring changes into effect. Select Restart now to reboot your PC.
Step 2: Download and Install a Linux Distribution on Your PC
Now that Windows Subsystem for Linux is installed, download your favorite Linux distribution and install it on your PC. You can install more than one Linux distro available on the Microsoft Store.
We’ll install the Ubuntu distro in the following steps.
- When your PC boots back up after the last step in the above section, open the Start menu, search for Microsoft Store, and select Microsoft Store in the search results.
- In the Store, select Search at the top-right corner and type Ubuntu. You may enter any other Linux distro name here if you want.
- Select Ubuntu in the search results.
- On Ubuntu’s app screen, select Install to install this Linux distribution on your PC. Windows will install this distro as if you’re installing any other Store app.
- Close Microsoft Store when Ubuntu is installed.
Step 3: Configure the Linux Bash Shell on Windows 10
The Linux Bash shell is now installed on your PC, and you’re ready to start using it.
When you run the shell for the first time, it’ll ask you to configure a few options. Here’s how to launch and configure the shell:
- Open the Start menu, search for Ubuntu, and select Ubuntu in the search results.
- When Ubuntu opens, it’ll start configuring some of its options automatically. Wait for this to finish.
- When you see the Enter new UNIX username prompt, type the username you’d like to use with the Bash shell. This username can be different from the one you use with your Windows user account. Then, press Enter.
- Ubuntu then asks you to create a password for the shell. Type a password and press Enter.
- Type the password again and press Enter.
- The window will display various messages. At the bottom of these messages, you’ll see the username you just created and your PC’s name.
- You can now start running Linux commands on your PC.
Step 4: Start Using Linux Bash Shell Commands on Windows 10
The Linux Bash shell is now fully configured, and you can start running your commands in it. If you aren’t sure what commands to start with, the following will give you some ideas.
Note that each command that starts with sudo will require you to enter the password you created in the above section. This is because these commands need admin privileges to run.
1. Update Package List
Command: sudo apt-get update
This command updates the packages list for your specific Linux distribution. Keep in mind that this command doesn’t actually install any updates; it only updates the list.
2. Install Software Updates
Command: sudo apt-get upgrade
Use this command to get updates for the apps installed on your Linux distribution.
3. Install a New Program
Command: sudo apt-get install PackageName
This command helps you install a program on your Linux distribution. Replace PackageName in the command with the name of the program you want to install.
For example, to install Audacity, you’d use the following command:
sudo apt-get install audacity
4. Remove an Installed Program
Command: sudo apt-get remove PackageName
To get rid of a program from your Linux distribution, use this command replacing PackageName with the name of the program you want to remove.
5. Edit a Text File
Command: nano FileName.txt
This command opens Ubuntu’s built-in text editor to let you edit the specified file. Make sure to replace FileName with the actual name of the file you want to edit.
6. List the Contents of a Directory
Command: ls (that’s a small L)
Use this command to display the contents of your current working directory.
7. Change the Current Directory
Command: cd Path
To change your current working directory, run this command replacing Path with the full path to the directory you want to make your new working directory.
8. Download Files From the Internet
Command: wget URL
You can download files from the internet to your computer with this command. Simply replace the URL in the command with the web address of the file you wish to download.
9. Clear the Terminal Screen
Command: clear
This command clears everything in your Terminal window and lets you start typing commands from scratch. Use this when your Terminal screen is too cluttered.
10. Quit the Terminal
Command: exit
This command closes the Terminal window. Use this when you’ve finished working with your commands.
And those are some of the essential commands you should learn to get started with the Linux Bash shell on your Windows 10 PC. We hope this guide helps you out.