Linux terminal inside MS Windows
Table of contents
Intro
Although Linux distros are getting much more popular and the features are increasing there, MS Windows does still have its own privileges especially for non-technical purposes such as gaming or dealing with heavy programs for editing pictures/music/videos or at least the MS Office (Which is surely much larger and deeper than Libre Office despite of their great effort to extend that). However, you -as a developer- might need to interact more with Linux (Especially the terminal) if you want to engage more with servers. What shall I do?
What shall I do?
The first solution that might come to your mind, let's drop the Windows and install any Linux system and deal with it.
The second solution is: let's make our laptop have dual boot, so I can login to Windows and in development, I can logout and login to Linux.
The third solution is using a VM, let's have a Virtual Machine, where we can have a complete installation of the Linux right on our machine.
The forth solution is using a docker image, which will only allow you to enter the terminal, while still running it on windows terminal which may feel a bit uncomfortable.
All the previous solutions have their pros and cons. However, running them in a very low memory laptop is not the best option (Except for the forth). The forth solution will still make you a bit uncomfortable because you're still using the windows terminal.
After a few research, I found the optimum solution that will guarantee you the best of both worlds. Roll up your sleeves!
WSL
Windows have a subsystem as Linux "Windows Subsystem for Linux (WSL)" which is disabled by default, so we can just enable it and with a few steps, we can have a Linux on our Windows
Enable WSL and install Ubuntu
Make sure your laptop virtualization is enabled from the BIOS
When starting the laptop enter the BIOS/UEFI settings (Check your laptop model to see how you can do so).
Look for settings named 'Intel Virtualization Technology', 'VT-x', 'Intel VT', 'AMD-V', or 'SVM Mode'.
Make sure this option is enabled.
Open PowerShell (Or Command Prompt) as Administrator.
Run the following command to enable WSL
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
Enable Virtual Machine Platform (required for WSL 2)
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Restart your computer then so everything take effect.
(Optional but recommended) Set WSL 2 as the default version from the PowerShell (Command Prompt) as administrator
wsl --set-default-version 2
At the end, do not forget to update the WSL from the PowerShell (Command Prompt)
wsl --update
After that, you can go to the Microsoft store and install Ubuntu
After installing, run it. It will take a few minutes then it will prompt to ask you to create a username and a password for your Ubuntu user
(Optional - Personal Recommendation) I also installed from the store this terminal, which allowed me to customize everything to feel exactly as I am using Linux
Final notes
- When you install your Ubuntu, it will have its own file structure, so to reach out to the windows, follow the following command to find your windows drivers.
cd /mnt/
You can not run commands like (chmod) on files that exists on windows, you shall copy them to your Linux drivers where you can have full access and control to modify permissions.
sudo mkdir ~/keys cp /mnt/c/key.pem ~/keys/ cd ~/keys sudo chmod 400 key.pem
Hope this article was helpful for you, since it was very helpful for me and I wanted to share the knowledge I gained in this part.