Kali subsystem installation tutorial (including pit avoidance guide, a must-see for novices!)

#copyright statement: The words in the picture that contain the words Zhihu@王威同学 are my accounts on Zhihu, not stolen articles! This article is more detailed than Zhihu! !

1. Open the extension required to install the Linux subsystem

Win+Qsearch功能


Check the required extensions. Hyper-V、Windows 虚拟机监控平台、适用于Linux的Windows子系统、虚拟机平台
Anyway, check all the virtual machines.

The microsoft store has the ubuntu subsystem and the kali subsystem. By default, only the C drive can be loaded (it seems to be)

To install WSL2, you need to run an additional thing:

Upgrade from WSL1 to WSL2

This article applies to systems that have already installed WSL1.

Upgrades come at a price! ! ! ! Startup will be slower! ! ! ! ! The following default wsl1, wsl2 method I will turn the font blue.

0. View the current WSL version number

Open PowerShell and execute the command

wsl -l -v

You can see the WSL version number. If the WSL version number is 1, some actions are required to upgrade to WSL2.

1. Check the system requirements to run WSL2

WSL2 has certain requirements for the system version. Select Win + R on the keyboard , enter winver , and press Enter to view the detailed version of the current system. Check the figure below to see if the requirements are met. If not, the system needs to be upgraded.

2. Enable the virtual machine function

WSL2 needs to use a virtual machine, so the virtual machine function needs to be enabled in the system.

Open PowerShell and execute the command:

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Restart the system.

After starting the system, it is best to check whether the virtual machine can start. Check it by,

Open  控制面版, the viewing method can be selected 大图标, click 程序与功能—> 启用或关闭Windows功能, check whether the content circled in the red box in the figure below is ticked; if not, you need to tick and click OK.

If you don't have an entry for Hyper-V, check out the article win10家庭中文版安装Hyper-V.

In addition, check whether the 任务管理器- 性能CPU 虚拟化is turned on, if it is not turned on, please refer to the article在BIOS中打开虚拟机

3. Download the Linux kernel update package

  1. Choose according to the system:
x64: https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi
arm64: https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_arm64.ms

2. Run the update package downloaded in the previous step.

4. Set the distribution version

Open PowerShell and execute the command:

wsl --set-version 分发版名称 版本号

For example, the command to set Ubuntu18.04 to WSL2 is wsl --set-version Ubuntu-18.04 2

This step will take some time and will appear if the installation was successful 转移成功.

If it appears Please enable the Virtual Machine Platform Windows feature and ensure virtualization is enabled in the BIOS, it means that the virtual machine is not enabled in the BIOS, please refer to another article 在BIOS中打开虚拟机.

illustrate

​WSL2 is based on a virtual machine, so it can run various tasks in the background, such as Docker, etc., but the corresponding problem is that it will occupy a part of the memory, and it can be stopped when it is not in use to save resources  wsl --shutdown .

Let me take Kali as an example:

After installation, there will be a shortcut with the word kali in the start menu, restart it first (this is not important), and after running, there will be a cmd in the simulated terminal. The operation is exactly the same as that of the terminal, and the font is a bit beautiful, so everyone can make do with it.

Simple popularization of commonly used commands: (this paragraph is original)

sudo: Add sudo (space) before all commands to execute as root.

apt-get: Advanced Package  Tool, also known as apt-get, is an application manager for Unix and Linux systems. The command is probably like this: (no need to execute, just look at it)

sudo apt-get install openvas #一款开源漏洞寻找工具
sudo apt-get update
sudo apt-get upgrade

After the "terminal" is opened, register the user first. It cannot be the same as the windows user name, and it cannot be root . You can't see the password when you enter it, so you just watch the keyboard and enter it. It doesn't matter if you make a mistake, the system will ask you to enter it again. After registration——

Change the source first. It is highly recommended to change the source in Windows. The kali subsystem does not even have a notepad by default, and it will annoy you if you pretend to be messy, especially the speed of the kali official source, which is faster than **Network Disk, can suffocate you. (Novices avoid pits!)

The method of changing the source of kali is as follows: (Windows is behind)

Update apt first: sudo apt-get update

Then install vim: sudo apt-get install vim

Then replace the source: sudo vim /etc/apt/sources.list, :wq!

#中科大
deb  Index of /kali/  kali-rolling main non-free contrib
deb-src  Index of /kali/  kali-rolling main non-free contrib
#阿里云
deb  http://mirrors.aliyun.com/kali  kali-rolling main non-free contrib
deb-src  http://mirrors.aliyun.com/kali  kali-rolling main non-free contrib
#清华大学
deb  Index of /kali/ | Tsinghua University Open Source Software Mirror Station | Tsinghua Open Source Mirror  kali- rolling main contrib non-free
deb-src  Index of /kali/ | Tsinghua University Open Source Mirror Station | Tsinghua Open Source Mirror  kali-rolling main contrib non-free
#浙大
deb  Index of /kali/  kali-rolling main contrib non-free
deb-src  Index of /kali/  kali-rolling main contrib non-free
#Neusoft University
deb  open source mirror station | Dalian Neusoft Institute of Information  kali-rolling/main non-free contrib
deb-src  open source mirror station | Dalian Neusoft Institute of Information  kali-rolling/main non-free contrib
#Official source
deb  Index of /kali  kali-rolling main non-free contrib
deb-src  Index of /kali  kali-rolling main non-free contrib
reproduced from msdn, the original link

Change the source of the WSL subsystem (Kali) under Windows, using binwalk, outguess and other tools Upload cancellation https://link.zhihu.com/?target=https%3A//blog.csdn.net/qq_33957603/article/details/119717481

Windows: WSL1 opens a path similar to the following

C:\Users\your name\AppData\Local\Packages\KaliLinux.54290C8133FEE_ey8k8hqnwqnmg\LocalState\rootfs\etc\apt

The list file inside, I opened it with notepad2, Notepad should also work, open it and change the source. Paste a set of deb into it and replace the original one (don’t change the official one! Change it to the University of Science and Technology of China!! Here, because CSDN will recognize some links directly into Index and the like, don’t use this, it will report an error, if you find it troublesome, go directly to Baidu, There are a lot on Baidu) Novices avoid pits!

wsl2: There is a linux on the left side of the resource manager at the bottom:

 

 

 

Here are two sources.list I do not understand, if it is a common phenomenon, just change both 

The next step is also very important, change the password for root.

sudo passwd root

You can't see the password either, just enter it with your eyes closed.

and then

sudo apt-get update

sudo apt-get dist-upgrade

To know what these commands are, see

Update and upgrade are updated what you?

First explain what update and upgrade are updated respectively:

    update is to download the metadata in the source. It includes what packages the source has, what version each package is, etc.
    upgrade is to decide which package to update according to the metadata downloaded by the update command (and obtain the location of each package at the same time).

ps: Before installing the software, you don’t need to upgrade, but you need to update. Because the old information points to the old version of the package, but after the source server is updated, the old package may be replaced by the new one, so you will encounter 404.. .

Author: James Swineson
Link: https://www.zhihu.com/question/21732981/answer/19143492
Source: Zhihu
——————————————————
Copyright statement: This article is a CSDN blog The original article of the main "Hangheng 8 Dao" complies with the CC 4.0 BY-SA copyright agreement. For reprinting, please attach the original source link and this statement.
Original link: https://blog.csdn.net/wangyezi19930928/article/details/54928201

The default kali does not have a graphical interface, install the graphical interface below: first sudo su, then——

apt-get install kali-desktop-xfce

apt-get install xorg xfce4 xrdp

The second little white pit point is here! Because this is a streamlined and brand-new kali (which computer system has you seen 200m) installation will report an error at the end:

E: Sub-process /usr/bin/dpkg returned an error code (1)

Solution: You still need to execute the above installation command first, and follow the following solution after an error occurs:


Rename the info folder

sudo mv /var/lib/dpkg/info /var/lib/dpkg/info.bk

Create a new info folder

sudo mkdir /var/lib/dpkg/info

install repair

sudo apt-get update
sudo apt-get install -f 

After performing the previous step, some files are generated under the info folder, and now all these files are moved to the info.bk folder

sudo mv /var/lib/dpkg/info/* /var/lib/dpkg/info.bk

delete the newly created info folder

sudo rm -rf /var/lib/dpkg/info

restore the original info folder, modify the name

sudo mv /var/lib/dpkg/info.bk /var/lib/dpkg/info

has been successfully installed here, but I also encountered missing related files, such as

/etc/apache2/mods-available/dav_svn.conf

But now at least it can be installed normally, simply uninstall and reinstall

sudo apt-get --purge remove libapache2-mod-svn 
sudo apt-get --purge remove libapache2-svn 
sudo apt-get autoremove

install side, back to normal
———————————————— —Copyright
statement: This article is an original article of CSDN blogger "Mr.Stick", following the CC 4.0 BY-SA copyright agreement, please attach the original source link and this statement for reprinting.
Original link: https://blog.csdn.net/stickmangod/article/details/85316142

Repair complete and execute again

apt-get install kali-desktop-xfce

apt-get install xorg xfce4 xrdp

Here is a popular science about what xrdp, xfce, and xorg are: (no operation required, will be taught later)

Installation instructions, xfce4 needs to select items in the middle, you need to pay attention:
sudo apt update -y && sudo apt upgrade -y && sudo apt install xorg -y && sudo apt install xfce4 -y && sudo apt install xrdp -y to get the
latest resource items

sudo apt update -y && sudo apt upgrade -y
#Install xorg (including a series of software packages such as graphics card driver, graphics environment library, etc.)

sudo apt install xorg
#Install xfce4 (running on a Unix-like operating system, providing a lightweight desktop environment)

sudo apt install xfce4
#Install xrdp (an open source Remote Desktop Protocol (RDP) server)

sudo apt install xrdp
#Configure xrdp (configure port), the default port number is 3389, the configuration here is assumed to be 9999

sudo sed -i 's/port=3389/port=9999/g' /etc/xrdp/xrdp.ini
#write xfce4-session to .xsession

sudo echo xfce4-session >~/.xsession
#Restart xrdp service

sudo service xrdp restart       
#Stop xrdp service:

sudo service xrdp stop
————————————————
Copyright statement: This article is an original article by CSDN blogger "LiuBeiRong", following the CC 4.0 BY-SA copyright agreement, please attach the original source for reprinting link and this statement.
Original link: https://blog.csdn.net/zyklbr/article/details/114321808

Next, we will use the remote control method to connect to the graphical interface of the subsystem : there is a new kex in the back, which realizes the kali official website

 

Win+r opens mstsc. (do not enter first)

In "terminal" (not cmd) enter:

sed -i 's/port=3389/port=3390/g' /etc/xrdp/xrdp.ini

Set the remote connection port. 3390 can be changed by yourself, don't change it to the port you are using.

echo xfce4-session >~/.xsession

service xrdp restart

#Restart the xrdp service, every time you restart windows in the future, you must enter this service xrdp restart in the terminal to start the virtual desktop!

Then edit the credentials in the remote connection, enter the user and password you registered at the beginning.

Finally, enter ipconfig in cmd (in the windows host) to view the local ip, as shown in the figure below, remember the ipv4 address. Enter something similar to my input "ip: port" in the remote control window

When I first entered, it was a black screen, wait a moment... (depending on the performance of the host machine, it will take a long time for the first time)

It's very nice to boot up and use it.

The following should be noted that kali cannot be shut down inside, unless you directly shut down Windows or if you want to shut down a separate kali, enter wsl --shutdown in the local powershell. In addition, if you want to use WSL, it is recommended to first understand the basic commands of WSL, and only link the basic commands of WSL https://learn.microsoft.com/zh-cn/windows/wsl/basic-commands?source=recommendations

Kali can't adjust the size and zoom of the display, let's make do with it (

 After exiting kali full screen, the remote window must be reduced first.

 The task manager can see the kali process

kex: Enter the following command

sudo apt install -y kali-win-kex

When finished, enter kex and enter a password. Will report an error, don't panic...

Then install xming on windows (too lazy to install it), install it and run it, configure it as follows

 

 At this time, the subsystem enters startxfce4! !

pretty!

My start menu will run around, has anyone solved it, please experience (

Attach a little WSL tutorial

Basic WSL commands

Linux distributions installed via WSL are best managed using PowerShell or the Windows Command Prompt (CMD). See the WSL Commands Reference Guide for a list of the basic commands you'll need to be familiar with when using WSL  .

In addition, many commands are interoperable between Windows and Linux. Here are a few examples:

Guess you like

Origin blog.csdn.net/CM_WangWei/article/details/128370255