apt install works the same way in WSL as on any Linux system
apt install is the command you type into Windows Subsystem for Linux to download and set up software packages. When you run apt install package-name, WSL connects to Ubuntu's package repository (the online storage where programs live), downloads the files, and installs them so you can use them from the command line.
The command works identically whether you're on a full Linux machine or inside WSL on Windows. The main difference is that WSL needs to be running first — you open it like any other Windows application, and then you type your commands into the terminal window that appears.
Before you can install anything, you need to update apt's list of available packages. This takes about 30 seconds and should be your first step after opening WSL for the first time, or after a long gap between uses.
Key Takeaways
- Run sudo apt update before installing anything to refresh the list of available packages.
- Install a single package with sudo apt install package-name, replacing package-name with the actual program you want.
- WSL will ask you to confirm the download size before proceeding — type y and press Enter to continue.
- If a package name contains multiple words, use hyphens instead of spaces, like sudo apt install build-essential.
- You need the sudo prefix because installing software requires administrator permissions in WSL.
Update apt before installing anything new
Open WSL and type this command exactly:
sudo apt update
Press Enter. WSL will ask for your password — type the password you created when you first set up WSL, then press Enter again. You won't see the characters as you type, which is normal.
The update process takes a minute or two. You'll see lines of text scrolling past showing which repositories are being checked. When it finishes, you'll see a prompt ready for the next command. This step refreshes apt's internal list so it knows which versions of which packages are currently available.
Install a single package with apt install
Once the update is complete, type:
sudo apt install package-name
Replace package-name with the actual name of what you want to install. For example, to install Git, you would type sudo apt install git. To install Node.js, type sudo apt install nodejs.
Press Enter. WSL will show you the download size and ask "Do you want to continue?" Type y and press Enter. The download and installation happen automatically — you'll see progress text as it works.
When it finishes, you're back at the prompt. The package is now installed and ready to use. You can verify this by typing the package name followed by --version, like git --version, to see what version you got.
Install multiple packages at once
You can install several packages in a single command by listing them with spaces between:
sudo apt install git nodejs python3 curl
This installs Git, Node.js, Python 3, and curl all in one go. WSL downloads and installs them sequentially, and you only need to confirm once. This is faster than running four separate install commands.
If any package name contains multiple words, use hyphens instead of spaces. For example, build-essential is a single package name, not two separate ones. The command sudo apt install build-essential python3-dev installs two packages correctly.
Find the correct package name when you're unsure
Package names in apt are sometimes different from what you'd expect. For instance, the Python package manager is called python3-pip, not just pip. If you try to install something and get an error saying the package wasn't found, you can search for it:
apt search search-term
Replace search-term with what you're looking for. For example, apt search python shows every package with "python" in its name or description. The output is long, so you can pipe it through a filter: apt search python | grep pip shows only lines containing "pip".
Once you find the correct name, copy it exactly and use it in your install command. Package names are case-sensitive and must match precisely.
Understand what happens when installation fails
If you see an error like "E: Unable to locate package", the package name is wrong or doesn't exist in Ubuntu's repositories. Double-check the spelling and try searching for it with apt search.
If you see "E: Could not open lock file", another process is using apt — usually an automatic update running in the background. Wait a minute and try again.
If you see "sudo: command not found" or permission errors, your WSL installation may be corrupted. Uninstall and reinstall WSL from the Microsoft Store, then run sudo apt update immediately after setup completes.
Remove packages you no longer need
To uninstall a package, type:
sudo apt remove package-name
This removes the program but leaves behind configuration files in case you reinstall it later. If you want to remove everything including configuration files, use sudo apt purge package-name instead.
After removing packages, you can clean up the downloaded installation files to save disk space:
sudo apt autoremove
This removes packages that were installed as dependencies for other packages but are no longer needed.
Frequently Asked Questions
Do I need sudo for every apt command?
Yes. Installing, removing, and updating packages all require administrator permissions, so sudo must come first. The only command that doesn't need it is apt search, which only reads information and doesn't change anything on your system.
What's the difference between apt install and apt-get install?
apt and apt-get do the same thing. apt is newer and slightly simpler to use, so it's the better choice for most people. Older tutorials sometimes show apt-get, but apt works identically in WSL.
Can I install Windows programs through apt?
No. apt only installs Linux packages that run inside WSL. If you need Windows software, install it normally through Windows. WSL can run Windows executables from the command line, but you don't install them through apt.
How do I know if a package is already installed?
Type package-name --version or which package-name. If the package is installed, you'll see its version number or file path. If it's not installed, you'll get a "not found" message.
Why does apt update take so long sometimes?
apt connects to multiple online repositories to check for updates. If your internet connection is slow or a repository server is busy, the process takes longer. Running sudo apt update once a week is usually enough — you don't need to do it before every install if you've done it recently.