+4

Cài Đặt Ubuntu trên Windows 11 Nhanh Chóng với WSL

Chạy dòng lện này để có thể cài WSL

wsl --install

Chắc rằng bạn đã bật Windows Subsystem for Linux

Cách bật WSL trên windows : Windows features on or off > Turn on Windows Subsystem for Linux, Virtual Machine Flatform, Hyper-V

Chạy dòng lệnh này để kiểm tra phiên bản và trạng thái của WSL. Chạy nó trong PowerShell hoặc Command Prompt:

wsl --version

Cài đặt

Kiểm tra các phiên bản distro

wsl --list --online

=> Kết quả

NAME                 FRIENDLY NAME
Ubuntu               Ubuntu
Debian               Debian GNU/Linux
kali-linux                             Kali Linux Rolling
Ubuntu-18.04                           Ubuntu 18.04 LTS
Ubuntu-20.04                           Ubuntu 20.04 LTS
Ubuntu-22.04                           Ubuntu 22.04 LTS
Ubuntu-24.04                           Ubuntu 24.04 LTS
OracleLinux_7_9                        Oracle Linux 7.9
OracleLinux_8_7                        Oracle Linux 8.7
OracleLinux_9_1                        Oracle Linux 9.1
openSUSE-Leap-15.5                     openSUSE Leap 15.5
SUSE-Linux-Enterprise-Server-15-SP4    SUSE Linux Enterprise Server 15 SP4
SUSE-Linux-Enterprise-15-SP5           SUSE Linux Enterprise 15 SP5
openSUSE-Tumbleweed                    openSUSE Tumbleweed
  • NAME: Tên viết tắt của bản phân phối.
  • FRIENDLY NAME: Tên đầy đủ của bản phân phối.

Sử dụng lệnh này để cài đặt phiên bản phân phối bạn muốn:

wsl.exe --install --d <NAME>

=> Trong trường hợp của tôi, tôi muốn tải xuống Ubuntu-22.04:

wsl.exe --install --d Ubuntu-22.04

=> Kết quả:

Ubuntu 22.04 LTS is already installed.
Launching Ubuntu 22.04 LTS...
Installing, this may take a few minutes...
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username: yor-username
New password:
Retype new password:
passwd: password updated successfully
Installation successful!
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

Welcome to Ubuntu 22.04.3 LTS (GNU/Linux 5.15.153.1-microsoft-standard-WSL2 x86_64) 

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage


This message is shown once a day. To disable it please create the
/home/phuclam/.hushlogin file.

LƯU Ý: Tại mục New passwordRetype new password, khi bạn nhập sẽ không hiển thị ký tự, nhưng đừng lo lắng, nó chỉ được ẩn đi khi bạn nhập.

Để thoát khỏi cửa sổ Ubuntu:

exit

Gỡ bỏ

Hiển thị tất cả các phiên bản bạn có trong thiết bị của mình:

wsl -l -v

Để gỡ bỏ bản phân phối, hãy sử dụng lệnh:

wsl --unregister <NAME>

Ví dụ:

wsl --unregister Ubuntu-22.04

Lỗi và Sự cố

  1. Lỗi: Phiên bản đã tồn tại

Nếu khi bạn chạy lệnh và nó hiển thị như thế này:

C:\Users\ACER>wsl.exe --install --d Ubuntu-22.04
Ubuntu 22.04 LTS is already installed.
Launching Ubuntu 22.04 LTS...
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

Đừng lo lắng, bạn chỉ cần gỡ cài đặt phiên bản bạn có và cài đặt lại nó. => Giải pháp:

wsl --unregister Ubuntu-22.04

Sau đó, bạn chỉ cần cài đặt lại nó với phiên bản bạn muốn. Chúc may mắn!!!

Lưu ý:

  • Nhớ thay <NAME> bằng tên bản phân phối bạn muốn cài đặt hoặc gỡ bỏ.
  • Nội dung kết quả output có thể khác nhau tùy thuộc vào phiên bản WSL và hệ điều hành Windows mà bạn đang sử dụng.

All rights reserved

Viblo
Hãy đăng ký một tài khoản Viblo để nhận được nhiều bài viết thú vị hơn.
Đăng kí