KI 3736 What is WSL2?
(updated )
At a glance
What is it?
A Windows 11 feature that runs a real Linux kernel in a lightweight virtual machine.
Who is it for?
Staff and students who need Linux tools for programming, research, data analysis or teaching.
What does it cost?
Nothing. WSL2 and the most common Linux distributions are free.
How do I get it?
Install it yourself from Software Center. See Installing and enabling WSL2 via Software Center.
How does it work?
Linux runs in a small virtual machine that Windows starts and stops automatically as needed. You'll barely notice it. Windows and Linux share the same hardware, and you can use both at the same time.- You choose the distribution. Ubuntu is the most popular, but you can also choose Debian, openSUSE, Fedora and others. You can have several installed at once.
- It's real Linux. Programs built for Linux work just as they would on a regular Linux machine.
- It starts quickly. Seconds, not minutes.
- It's closely integrated with Windows. You can copy and paste between Windows and Linux, open Linux files in File Explorer, and use Windows programs such as Visual Studio Code to work on files in Linux.
What can WSL2 be used for?
💻 Programming
Many programming languages and development tools work best on Linux, or assume Linux. With WSL2 you can use Python, R, C/C++, Java, Node.js, Rust and more in a Linux environment, while editing your code in Visual Studio Code on Windows.📊 Research and data analysis
A lot of research software is developed primarily for Linux, for example in bioinformatics, geoscience and statistics. WSL2 lets you use these tools without a separate Linux machine.⌨️ Command line and scripts
If you need bash, ssh, git, rsync or other classic Unix tools, they're ready to use. WSL2 is also handy if you connect to Linux servers or compute clusters and want the same environment locally.📦 Containers
Docker and Podman can use WSL2 as their foundation, so you can run containers on your Windows PC.🎓 Teaching and courses
If a course requires Linux, you can use WSL2 instead of a separate Linux machine or dual boot.🌐 Web and servers
Test websites, databases and services locally, in an environment similar to the server they'll run on.Files between Windows and Linux
Windows and Linux each have their own file system, but they can read each other's files.- From Linux, your Windows files are under /mnt/c/. For example, your Windows home folder is at /mnt/c/Users/username.
- From Windows, your Linux files are in File Explorer under Linux in the left-hand pane, or you can type \\wsl.localhost\Ubuntu\home in the address bar.
Important: Files in the Linux file system are not included in the backup of your home directory or in OneDrive. Store important data somewhere that is backed up.
Graphical Linux programs
On Windows 11, WSL2 can also run Linux programs with a graphical user interface. The feature is called WSLg. The programs open in their own windows on your desktop, just like regular Windows programs.Your responsibilities when using WSL2
Inside the Linux environment, you are the administrator. That gives you a lot of freedom, and also some responsibility:- Keep Linux up to date. UiB IT updates Windows automatically, but not the software inside your Linux distribution. Run updates regularly:
- Only install software from sources you trust. Use your distribution's official package repository where possible (apt in Ubuntu).
- Remember your Linux password. It's used with sudo and is not the same as your UiB password.
- Follow UiB's information security rules. The same rules for storing and handling data apply in Linux as in Windows. Se the storage guide for more information: KI 2928
When don't you need WSL2?
WSL2 is a tool for people who need Linux. You don't need it if you only use everyday office software, a web browser, Teams and similar.WSL2 is also not the best choice if you need:
- a full Linux desktop as your main working environment
- direct access to special hardware, such as certain USB devices or measuring instruments
- to run Linux services that others on the network should be able to reach over time
Glossary
Linux
A free, open-source operating system widely used on servers and in research.
Distribution
A "flavour" of Linux, such as Ubuntu or Debian. Each has its own tools and default settings.
Kernel
The innermost part of the operating system, which talks to the hardware.
Terminal
A window where you type commands instead of clicking.
sudo
A command that lets you run something with administrator rights in Linux.
apt
The program Ubuntu and Debian use to install and update software.
Virtual machine
A computer that runs as a program inside another computer.