Windows Subsystem for Linux is an advanced feature for Windows users. Windows Subsystem for Linux allows you to practice and learn Linux operating system commands directly on your Windows 10 system without using virtual machine software such as VirtualBox.
Windows Subsystem for Linux, also known as WSL for short, is implemented by Microsoft in Windows 10 and Windows Server 2019 operating systems, to provide compatibility and execution of Linux binaries.
To install Linux Distro images in general, users have to rely on the Microsoft Store, which has a number of precompiled lightweight images. Currently, the Linux WSL images available are Ubuntu, Kali Linux, Debian, AlpinLinux, OpenSUSE and SUSE Enterprise Server. Therefore, if you want to try some Linux operating systems like CentOS/RHEL (Red Hat Enterprise Linux) and Arch Linux then you have to install them yourself on Windows 10 Subsystem for Linux. Today’s article will show you how to do that.
Note: Before installing CentOS on WSL, you must activate the Windows Subsystem for Linux. If you don’t know how to do that, then read the article: Run Linux on Windows 10 without a virtual machine, here are 18 things you should know for more details.
How to Install CentOS on Windows 10 Subsystem for Linux
Step 1: Download CentOS WSL
The first thing required is a CentOS on WSL (Windows 10 FCU or later), based on WSldl. It’s basically a compressed file that contains rootfs and some other files. CentOS as WSL Instance is an open source project available on Github, so get it here. The latest version at the time of writing is CentOS 7.6.
Step 2: Extract the WSL CentOS 7.x folder
The size of the downloaded folder will be around 300MB and after downloading, right click to extract this folder. Here, the article is using WinRAR to extract the files. However, you can use the default Windows program or any other option to extract it.
Step 3: Run CentOS.exe to install CentOS on Windows 10 Subsystem for Linux
After extracting the folder, you will see 2 files in it: The first file is rootfs.tar.gz and the second file is CentOS.exe. You need to run CentOS.exe to extract the files and register them on WSL. Right click on the file and select Run as administrator.
Step 4: Complete the installation
Once the installation is complete, you will receive a message on the CentOS command screen. Now, press the Enter key to exit the setting.
Step 5: Run CentOS 7 on WSL
To run CentOS 7, again go to the extracted folder of CentOS for WSL and this time you will see 4 files. Again, right click on Centos.exe and select Run as administrator.
Finally, the manually installed Linux subsystem for CentOS is here.
Step 6: Command to update CentOS on WSL
You can run any command you want to execute on CentOS, just to check if it works fine. The example is running the command to update CentOS using YUM.
yum -y update
Step 7: Uninstall CentOS 7 WSL
If in the future you accidentally delete the CentOS WSL folder and want to reinstall it, you need to delete the existing installation first.
To uninstall CentOS 7 WSL just use below single command:
Then again extract the files from the CentOS zipped folder you downloaded above and then run Windows 10 PowerShell with admin rights, navigate to the extracted folder and run the command below:
To reinstall, run the executable CentOS.exe in the same extracted folder to register the files to the Windows 10 Subsystem for Linux.
Hope you are succesful.