How to Use apt install in WSL (Windows Subsystem for Linux)

If you've set up WSL on your Windows machine, you're running a real Linux environment — which means you have access to APT, the package manager used by Debian-based distributions like Ubuntu. Understanding how apt install works inside WSL unlocks the ability to install development tools, servers, utilities, and language runtimes without ever leaving Windows.

What Is apt and Why Does It Work in WSL?

APT (Advanced Package Tool) is the standard package management system for Debian and Ubuntu Linux distributions. When you install WSL with Ubuntu (the default distro), you get a fully functional Linux userland, including APT and its package repositories.

Because WSL runs an actual Linux kernel (in WSL 2) or a compatibility layer (WSL 1), the package manager behaves almost identically to how it would on a native Linux machine. This means apt install fetches real Linux packages from Ubuntu's official servers, resolves dependencies automatically, and installs binaries your Linux environment can run.

Running Your First apt install Command

The basic syntax is straightforward:

sudo apt install package-name 

The sudo prefix is necessary because installing software requires elevated (root-level) permissions. APT will:

  1. Check its local package list for the package
  2. Identify any dependencies that also need to be installed
  3. Show you a summary and ask for confirmation
  4. Download and install everything

Example — installing the curl utility:

sudo apt install curl 

APT will confirm what it plans to install, prompt you to type Y to proceed, and then handle the rest automatically.

Update Before You Install

One of the most common mistakes in WSL is skipping the update step. APT maintains a local cache of available packages, and this cache can go stale quickly — especially on a fresh WSL install.

Before installing anything, run:

sudo apt update 

This refreshes the package index from Ubuntu's repositories. It does not install or upgrade anything — it just syncs the list of what's available. Follow it with your install command.

If you also want to upgrade already-installed packages:

sudo apt upgrade 

Running apt update && apt upgrade together before a new install is considered standard practice.

Installing Multiple Packages at Once 🛠️

You can chain multiple packages in a single command:

sudo apt install git nodejs npm python3 

APT resolves all dependencies together, which is more efficient than installing them one at a time.

Common Packages Developers Install in WSL

PackageWhat It Does
gitVersion control
curl / wgetHTTP requests and file downloads
python3Python runtime
nodejs / npmJavaScript runtime and package manager
build-essentialGCC compiler and core build tools
nginxWeb server
postgresqlRelational database
unzipArchive extraction

The availability of any package depends on your distro version and its configured repositories.

Variables That Affect How apt install Behaves

Not every WSL setup works identically. Several factors shape what you can install and how the process runs:

WSL version (1 vs. 2): WSL 2 uses a real Linux kernel, which means better compatibility with packages that need kernel-level features. Some tools — particularly those involving networking, filesystem performance, or Docker integration — behave differently or fail entirely on WSL 1.

Ubuntu version: The packages available through APT depend on which Ubuntu release you're running (e.g., 20.04, 22.04, 24.04). Newer distro versions carry newer package versions in their default repositories, but older LTS releases may have more stable, battle-tested packages.

Repository configuration: By default, WSL Ubuntu includes the official Ubuntu repositories. Some packages — particularly newer versions of Node.js, PHP, or databases — require you to add a PPA (Personal Package Archive) or third-party repository before apt install can find them.

Network and proxy settings: WSL inherits your Windows network connection, but corporate proxies, VPNs, or firewall rules can block APT from reaching Ubuntu's servers. If apt update hangs or fails, your network configuration is usually the first place to investigate.

User permissions: If you're not set up with a default sudo-capable user, apt install will fail. Most WSL setups handle this automatically during initial configuration, but custom or automated installs sometimes skip it.

When apt install Can't Find a Package 🔍

If APT returns a "package not found" error, there are a few likely causes:

  • Stale package cache — run sudo apt update first
  • Package has a different name — use apt search keyword to find the correct package name
  • Package isn't in the default repos — you may need to add a PPA or use an alternative installer like snap, pip, or nvm
  • Wrong architecture — rare in WSL, but some packages only target specific CPU architectures

How This Fits Into a WSL Development Workflow

For web developers, apt install is typically the entry point for setting up a local development environment: installing compilers, runtimes, version managers, and servers. From there, language-specific tools (like pip for Python or npm for Node) take over for project-level dependencies.

The line between what belongs in APT versus what should be handled by language-level package managers or version managers (like nvm for Node or pyenv for Python) is a real decision point. APT-installed versions are stable and system-wide but often lag behind current releases. Language-specific version managers give you more flexibility but add complexity.

Which approach fits depends entirely on the kind of projects you're running, how many different runtime versions you need to juggle, and how your team's environment is configured.