- Posted on
- • Administration
Using WSL (Windows Subsystem for Linux) with APT
- Author
-
-
- User
- Linux Bash
- Posts by this author
- Posts by this author
-
Embracing Linux on Windows: A Guide to Using WSL with APT, DNF, and Zypper
With the increasing need for powerful cross-platform development environments, the integration of Linux capabilities in Windows through WSL (Windows Subsystem for Linux) has become a game-changer. WSL allows users on Windows 10 and Windows 11 to run a Linux distribution alongside their Windows applications, offering remarkable flexibility.
This dual capability enriches your environment to manage and deploy software using popular Linux package managers like APT, DNF, and Zypper. Whether you are a developer, a systems administrator, or just a tech enthusiast, mastering these tools within WSL can enhance your workflow significantly. In this guide, we'll dive deep into using these package managers efficiently in WSL.
Setting Up WSL
Before diving into the package managers, ensure that your system has WSL enabled and configured. Here's a brief rundown:
- Enable WSL on Windows: Open PowerShell as Administrator and run:
wsl --install
. This command installs the WSL feature and the default Linux distribution, which is Ubuntu. - Set up your Linux distribution: Once installed, launch the Linux distribution from your start menu, and set up the user account and password.
Now that you have WSL set up, let’s explore how to use APT (Debian and Ubuntu), DNF (Fedora), and Zypper (openSUSE).
Using APT in Ubuntu on WSL
APT (Advanced Package Tool) is the package manager used by Debian and Ubuntu distributions. It is known for its simplicity and efficiency in managing packages.
- Updating Package Lists: Before you install or upgrade packages, it's good practice to update your package lists:
sudo apt update
- Installing Packages: To install a package, you use:
sudo apt install [package_name]
For example, to install Vim, you would run:sudo apt install vim
- Searching for Packages: If you are unsure of the exact package name, you can search using:
apt search [search_term]
- Upgrading Packages: To upgrade all your installed packages to their latest versions:
sudo apt upgrade
Using DNF in Fedora on WSL
DNF (Dandified YUM) is the next-generation version of YUM and is used by Fedora. It resolves dependencies more efficiently and has a robust plugin system.
- Updating Package Database: Start by updating the DNF package database:
sudo dnf check-update
- Installing Packages: To install software, use:
sudo dnf install [package_name]
For instance:sudo dnf install nano
- Search for Packages: You can search for packages with:
dnf search [keyword]
- Upgrade Packages: To update all packages:
sudo dnf upgrade
Using Zypper in openSUSE on WSL
Zypper is a command-line interface of the ZYpp package manager for installing, updating and removing packages as well as for managing repositories.
- Refresh Repositories: Before any operations, ensure your repositories are up-to-date:
sudo zypper refresh
- Installing Software: Install a new package by:
sudo zypper install [package_name]
Example:sudo zypper install lsof
- Searching Packages: For searching packages use:
zypper search [query]
- System Update: To perform a system-wide update:
sudo zypper update
Conclusion
WSL has undeniably opened new possibilities for Windows-based systems, breaking the boundary between Windows and Linux tools. By using APT, DNF, or Zypper, you can manage software packages from Linux directly on Windows, making it extremely flexible for developers who need a diverse toolkit. Embrace WSL and streamline your development tasks more effectively while enjoying the robustness of Linux tools on a Windows machine!