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:

  1. 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.
  2. 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.

  1. Updating Package Lists: Before you install or upgrade packages, it's good practice to update your package lists: sudo apt update
  2. 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
  3. Searching for Packages: If you are unsure of the exact package name, you can search using: apt search [search_term]
  4. 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.

  1. Updating Package Database: Start by updating the DNF package database: sudo dnf check-update
  2. Installing Packages: To install software, use: sudo dnf install [package_name] For instance: sudo dnf install nano
  3. Search for Packages: You can search for packages with: dnf search [keyword]
  4. 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.

  1. Refresh Repositories: Before any operations, ensure your repositories are up-to-date: sudo zypper refresh
  2. Installing Software: Install a new package by: sudo zypper install [package_name] Example: sudo zypper install lsof
  3. Searching Packages: For searching packages use: zypper search [query]
  4. 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!