How to install Linux on Windows
If you own a Windows computer and would like to try out the Linux operating system, there is an easy way to quickly get a taste of what it would be if your computer ran on Linux.
Windows Subsystem for Linux (WSL) is a virtual machine that isn’t resource-intensive and enables you to run Linux side by side with your Windows OS. WSL can even interact with the Windows file system, thus providing more functionality.
Even if you are not experienced in using Linux, getting WSL to run on your computer shouldn’t be difficult as long as you follow the steps that we will provide you with within this post.
What will Windows Subsystem for Linux provide you with?
Installing WSL isn’t the same as making the operating system of your computer Linux. Instead, as we said, this is a virtual machine that offers Linux functions but is run within the Windows OS. You will have access to Debian, Ubuntu, openSUSE, SLES, and Kali. Most of the functionality of an actual Linux OS install will be provided to you by WSL – command-line tools, Bash shell, and Linux command-line apps will all be available to you. However, one thing that you won’t get with WSL is a Linux GUI (Graphical User Interface) – the whole virtual machine is command-line based so you will need to learn Linux commands in order to use it. The plus side of this is that you will, at any time, be able to quickly and easily switch from Windows to WSL and vice versa which is perfect for users who are just getting introduced to the Linux OS.
How to install Window Subsystem for Linux
The one and only requirement that you’d need to meet in order to proceed is to have an up-to-date Windows 10 OS on your computer so make sure that you are running on the latest version of Windows 10.
- First, you’d need to access PowerShell – to do that, type powershell in the Start Menu search box and right-click on the PowerShell icon. Select Run as Administrator to start the app.
- Copy-paste this script into the PowerShell: dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart.
- Hit the Enter button and, if asked to restart the computer, do it.
- Next, go to Microsoft Store and type Linux in the search box.
- There will be different options for Linux installs but here we will go for Ubuntu. Click on the Install option below the Ubuntu icon and wait for the installation to complete.
- Launch Ubuntu once it gets downloaded and installed. It will get added to your Start Menu from where you can easily access it in the future.
- Set up a username and password.
- To get the latest update, use the “sudo apt update && sudo apt upgrade” command.
- The sudo apt install [name of package] allows you to install different packages.
Introduction to Linux – some basic commands
If this is indeed the first time you try Linux, you will have to learn about some of the most important Linux commands. Here is a list of six of those commands that will hopefully help you with the use of the Linux OS:
“Man” stands for manual and this command, when used, will show you a help document for every other Linux terminal command. Simply type man [command name] to access the manual for any given command, function, or file you want to learn more about. Even the man command itself has such a help document that can be opened by typing man man. This command is one of the most helpful ones for users who are new to Linux.
The Ls command allows you to see the files and directories that reside throughout the system. Simply typing Ls in the terminal will give you information about the files and folders that reside in the current directory. Adding different switches to the command will change the displayed results:
- Use Ls -L to see the size, modification date and time, permissions, and owners of files and folders.
- Ls -Ls will sort the files in the current directory by size.
- If you want information about a directory different from the current working one, type Ls -L [name of directory].
Cd allows you to change the current working directory – type cd [path of new directory] to use the command. Typing cd ~. will change the working directory to the user’s home directory.
When ifconfig is used, this will provide you with information about the IP address of the device. This command has a number of uses. For example, ifconfig [interface name] allows you to see the network settings of a given interface and ifconfig [interface name] down and ifconfig [interface name] up will disable/enable a specific network interface.
This command will help you find specific files. To use it, type find [name of file + file extension]. If, for instance, you want to find all files from a specific format, use the find -name *.jpeg.
“Clear” has one single use and that is to clear the terminal from everything that’s on it so that your screen isn’t cluttered with distracting text.
Since you will be using a Windows subsystem for Linux, we want to tell you about the wsl command. What wsl does is it basically allows you to execute Linux commands from a Windows terminal such as PowerShell or even the command prompt. Simply type wsl before the Linux command you want to execute and then type the actual command. For example, try using the Ls command from Windows PowerShell by typing wsl Ls. As we told you earlier, this will list the contents of your current working directory but you can now launch the command from a Windows terminal. One of the main advantages of this Linux virtual machine is the option to use the wsl command.
Accessing Windows folders and editing files in them through the Linux terminal
As we pointed out above, another unique feature of WSL is that there could be interaction between the Linux virtual machine and the file system of your Windows computer. Here is a simple example of how you can access a Windows directory and edit files in it using the Linux terminal (Ubuntu, in our case):
- Open the terminal (easiest way to access it is from the Start Menu).
- Enter the cd /mnt/c command to access the Windows C:\ drive.
- If you want to confirm that you have accessed the C: drive, use the Ls command.
- Now, try to create a new directory with the help of the mkdir command: type mkdir [name_of_new_directory] and hit Enter. You can confirm that a folder has been created by using Windows File Explorer.
- Now, access the new directory by entering the cd /mnt/c/[name_of_new_directory].
- Next, create a file in it with the command touch [name_of_file.txt].
- To edit the new file, try the nano [name_of_file.txt] command. Type a couple of words to add to the file.
- Press the Ctrl + 0 keys from the keyboard – this will save the changes to the file.
- Now, press Ctrl + X in order to exit.
- Finally, you can check the changes made to the file from the Windows interface by going to the folder where the file was saved and opening it.
Accessing Linux files from Windows
Lastly, we want to show you how you can access Linux files using the GUI provided by Windows. To do that, open the Linux terminal and type the explorer.exe command followed by the directory you want to open using Windows explorer. If you want to access the current working directory for your WSL, simply add “.” at the end of the command since this stands for the current directory (explorer.exe .). Needless to say, you can use the .exe command to launch regular Windows programs and open Windows directories through the Linux terminal. For instance, typing notepad.exe in the terminal will open the Windows Notepad app.
Now that you have the basics on how you can use Linux on your Windows computer without the need to install a new OS and remove your current one, you can easily start experimenting with different commands, use programming languages, run other Linux distros (Linux-based operating systems), and more. There are mountains of useful information online on how to operate within the Linux OS but we must advise you to never try anything that you aren’t sure about. Otherwise, you may end up bricking your computer, thus making it unusable.