Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
# enable VirtualMachinePlatform (needed by WSL 2)
PS C:\Users\Administrator> Enable-WindowsOptionalFeature -online -FeatureName VirtualMachinePlatform
Do you want to restart the computer to complete this operation now?
[Y] Yes [N] No [?] Help (default is "Y"): N
Path :
Online : True
RestartNeeded : True
# install WSL
# for the question after installing, answer [Y] to restart computer
PS C:\Users\Administrator> Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
Do you want to restart the computer to complete this operation now?
[Y] Yes [N] No [?] Help (default is "Y"): Y
Path :
Online : True
RestartNeeded : True
PS C:\Users\Administrator> wsl --update
Downloading: Windows Subsystem for Linux 2.3.26
Installing: Windows Subsystem for Linux 2.3.26
Windows Subsystem for Linux 2.3.26 has been installed.
The operation completed successfully.
Checking for updates.
The most recent version of Windows Subsystem for Linux is already installed.
PS C:\Users\Administrator> wsl --status
Default Version: 2
PS C:\Users\Administrator> wsl -l -o
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
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.6 openSUSE Leap 15.6
SUSE-Linux-Enterprise-15-SP5 SUSE Linux Enterprise 15 SP5
SUSE-Linux-Enterprise-15-SP6 SUSE Linux Enterprise 15 SP6
openSUSE-Tumbleweed openSUSE Tumbleweed
# for example, install Ubuntu 24.04
PS C:\Users\Administrator> wsl --install Ubuntu-24.04
Downloading: Ubuntu 24.04 LTS
Installing: Ubuntu 24.04 LTS
Ubuntu 24.04 LTS has been installed.
Launching Ubuntu 24.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: serverworld # set default user account (any name you like)
New password: # set default user 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 24.04 LTS (GNU/Linux 5.15.167.4-microsoft-standard-WSL2 x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/pro
System information as of Wed Jan 15 18:38:09 PST 2025
System load: 0.81 Processes: 43
Usage of /: 0.1% of 1006.85GB Users logged in: 0
Memory usage: 5% IPv4 address for eth0: 172.18.176.117
Swap usage: 0%
This message is shown once a day. To disable it please create the
/home/serverworld/.hushlogin file.
serverworld@rx-7:~$
# for Windows resource, it is mounted on [/mnt/c], possible to access
serverworld@rx-7:~$ df -h
Filesystem Size Used Avail Use% Mounted on
none 3.9G 0 3.9G 0% /usr/lib/modules/5.15.167.4-microsoft-standard-WSL2
none 3.9G 4.0K 3.9G 1% /mnt/wsl
drivers 80G 16G 64G 21% /usr/lib/wsl/drivers
/dev/sdc 1007G 1.2G 955G 1% /
none 3.9G 72K 3.9G 1% /mnt/wslg
none 3.9G 0 3.9G 0% /usr/lib/wsl/lib
rootfs 3.9G 2.2M 3.9G 1% /init
none 3.9G 496K 3.9G 1% /run
none 3.9G 0 3.9G 0% /run/lock
none 3.9G 0 3.9G 0% /run/shm
tmpfs 4.0M 0 4.0M 0% /sys/fs/cgroup
none 3.9G 76K 3.9G 1% /mnt/wslg/versions.txt
none 3.9G 76K 3.9G 1% /mnt/wslg/doc
C:\ 80G 16G 64G 21% /mnt/c
D:\ 160G 644M 160G 1% /mnt/d
tmpfs 794M 16K 794M 1% /run/user/1002
# resources that require root privileges on the Linux side can be accessed by the default user you set using [$ sudo (command)]
serverworld@rx-7:~$ sudo ls -la /root
total 24
drwx------ 4 root root 4096 Jan 15 18:37 .
drwxr-xr-x 22 root root 4096 Jan 15 18:43 ..
-rw-r--r-- 1 root root 3106 Apr 22 2024 .bashrc
drwx------ 2 root root 4096 Jan 15 18:37 .cache
-rw-r--r-- 1 root root 0 Jan 15 18:37 .motd_shown
-rw-r--r-- 1 root root 161 Apr 22 2024 .profile
drwx------ 2 root root 4096 Jan 15 18:37 .ssh
# to back to powershell, run exit
serverworld@rx-7:~$ exit
logout
# to run linux again, do like follows
PS C:\Users\Administrator> wsl -d Ubuntu-24.04
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
serverworld@rx-7:/mnt/c/Users/Administrator$
|