Cài đặt Ubuntu trên Windows sử dụng WSL

Cài đặt Ubuntu trên Windows sử dụng WSL

1. Cài đặt WSL command

Lưu ý: Mở cửa sổ cmd run as admin

wsl --install

2 Kiểm tra wsl version

wsl -l -v

WSL version: 2.0.14.0

Kernel version: 5.15.133.1-1

WSLg version: 1.0.59

MSRDC version: 1.2.4677

Direct3D version: 1.611.1-81528511

DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp

Windows version: 10.0.22631.2861

Nếu WSL đang là version 1 cần cài đặt và chuyển version 2

wsl --set-default-version <Version#>

wsl --set-default-version 2

3 Liệt kê các distro linux mà window đang suport

wsl --list --online

The following is a list of valid distributions that can be installed.

Install using ‘wsl.exe –install <Distro>’.

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

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

4 Cài đặt distro

wsl --install -d <Distro name>

wsl --install -d Ubuntu-22.04

5 Thiết lập phiên bản mặc định sử dụng với wsl

wsl -s <DistributionName> or wsl --set-default <DistributionName>

C:\Windows\System32>wsl -s Ubuntu-22.04

The operation completed successfully.

C:\Windows\System32>

6. Mount USB vào Linux

Cài đặt thêm gói thông qua PowerShell
Mở command prompt run as admin:

winget install usbipd

Liệt kê các USB đang nhận trên máy windows và attache vào wsl:

usbipd list

usbipd attach --wsl --busid 1-1

Vào wsl Ubuntu kiểm tra:

lsusb

Kết nối từ máy window vào máy ảo wsl

ssh localhost

Có thể tao key file… cấu hình tùy chỉnh host trong file cấu hình của chương trình ssh client của windows

C:\Users\<username>\.ssh

C:\Users\admin\.ssh>ls
config id_rsa id_rsa.pub known_hosts

cat C:\Users\admin\.ssh\config

Host *
User chint
IdentityFile ~/.ssh/id_rsa

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply