Running Ubuntu / Kali in Windows Subsystem for Linux - NETSEC

Latest

Learning, Sharing, Creating

Cybersecurity Memo

Monday, January 13, 2025

Running Ubuntu / Kali in Windows Subsystem for Linux

The Windows Subsystem for Linux (WSL) lets developers install a Linux distribution (such as Ubuntu, OpenSUSE, Kali, Debian, Arch Linux, etc) and use Linux applications, utilities, and Bash command-line tools directly on Windows, unmodified, without the overhead of a traditional virtual machine or dualboot setup.



Related Post:



Install WSL

You can now install everything you need to run WSL with a single command. Open PowerShell or Windows Command Prompt in administrator mode by right-clicking and selecting "Run as administrator", enter the wsl --install command, then restart your machine.


wsl --install


This command will enable the features necessary to run WSL and install the Ubuntu distribution of Linux. (This default distribution can be changed).




Kali-Linux

Microsoft Store





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: kali
New password:
Retype new password:
passwd: password updated successfully
Installation successful!
┏━(Message from Kali developers)
┃
┃ This is a minimal installation of Kali Linux, you likely
┃ want to install supplementary tools. Learn how:
┃ ⇒ https://www.kali.org/docs/troubleshooting/common-minimum-setup/
┃
┗━(Run: “touch ~/.hushlogin” to hide this message)
┌──(kali㉿NETSEC)-[~]
└─$

Set up your Linux user info

Once you have installed WSL, you will need to create a user account and password for your newly installed Linux distribution.




┌──(kali㉿NETSEC)-[/etc/init.d]
└─$ sudo -i
[sudo] password for kali:
┏━(Message from Kali developers)
┃
┃ This is a minimal installation of Kali Linux, you likely
┃ want to install supplementary tools. Learn how:
┃ ⇒ https://www.kali.org/docs/troubleshooting/common-minimum-setup/
┃
┗━(Run: “touch ~/.hushlogin” to hide this message)
┌──(root㉿NETSEC)-[~]
└─# apt update
Get:1 http://kali.mirror.rafal.ca/kali kali-last-snapshot InRelease [41.5 kB]
Get:2 http://kali.mirror.rafal.ca/kali kali-last-snapshot/main amd64 Packages [20.3 MB]
Get:3 http://kali.mirror.rafal.ca/kali kali-last-snapshot/main amd64 Contents (deb) [49.4 MB]
Get:4 http://kali.mirror.rafal.ca/kali kali-last-snapshot/contrib amd64 Packages [112 kB]
Get:5 http://kali.mirror.rafal.ca/kali kali-last-snapshot/contrib amd64 Contents (deb) [274 kB]
Get:6 http://kali.mirror.rafal.ca/kali kali-last-snapshot/non-free amd64 Packages [197 kB]
Get:7 http://kali.mirror.rafal.ca/kali kali-last-snapshot/non-free amd64 Contents (deb) [877 kB]
Get:8 http://kali.mirror.rafal.ca/kali kali-last-snapshot/non-free-firmware amd64 Packages [10.6 kB]
Get:9 http://kali.mirror.rafal.ca/kali kali-last-snapshot/non-free-firmware amd64 Contents (deb) [23.1 kB]
Fetched 71.2 MB in 5s (14.5 MB/s)
All packages are up to date.

┌──(root㉿NETSEC)-[~]
└─#



Ubuntu





Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows

Loading personal and system profiles took 1148ms.
PS C:\Users\netsec> wsl --install
Ubuntu is already installed.
Launching Ubuntu...
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

PS C:\Users\netsec> 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


Set up your Linux user info

Once you have installed WSL, you will need to create a user account and password for your newly installed Linux distribution.




WSL Commands

 
You can list your installed Linux distributions and check the version of WSL each is set to by entering the command: wsl -l -v in PowerShell or Windows Command Prompt.

PS C:\Users\netsec> wsl -l -v
  NAME          STATE           VERSION
* Ubuntu        Running         2
  kali-linux    Stopped         2


WSL supports running as many different Linux distributions as you would like to install. This can include choosing distributions from the Microsoft Storeimporting a custom distribution, or building your own custom distribution.

There are several ways to run your Linux distributions once installed:

  • Install Windows Terminal (Recommended) Using Windows Terminal supports as many command lines as you would like to install and enables you to open them in multiple tabs or window panes and quickly switch between multiple Linux distributions or other command lines (PowerShell, Command Prompt, Azure CLI, etc). You can fully customize your terminal with unique color schemes, font styles, sizes, background images, and custom keyboard shortcuts. Learn more.
  • You can directly open your Linux distribution by visiting the Windows Start menu and typing the name of your installed distributions. For example: "Ubuntu". This will open Ubuntu in its own console window.
  • From Windows Command Prompt or PowerShell, you can enter the name of your installed distribution. For example: ubuntu
  • From Windows Command Prompt or PowerShell, you can open your default Linux distribution inside your current command line, by entering: wsl.exe.
  • From Windows Command Prompt or PowerShell, you can use your default Linux distribution inside your current command line, without entering a new one, by entering:wsl [command]. Replacing [command] with a WSL command, such as: wsl -l -v to list installed distributions or wsl pwd to see where the current directory path is mounted in wsl. From PowerShell, the command get-date will provide the date from the Windows file system and wsl date will provide the date from the Linux file system.





No comments:

Post a Comment