What apt install does and when you need it

apt install is the command you type into Windows Subsystem for Linux (WSL) to read and set up software packages — libraries, tools, programming languages, databases, and utilities that your projects depend on. When you are working in WSL and need something that is not already there, apt install fetches it from Ubuntu's package repositories (the official storage of vetted software) and puts it on your system in the right places so your code can find it.

You use apt install when you need a specific tool for development work. If you are building a Node.js project and need PostgreSQL, or writing Python code that requires a particular library, or setting up a web server, apt install is how you get those things into WSL without hunting for read links or wrestling with installation wizards.

The command works because WSL runs a real Linux distribution — usually Ubuntu — inside Windows. Ubuntu uses apt (Advanced Package Tool) as its package manager, so the same commands you would type on a Linux server work exactly the same way in WSL.

Key Takeaways

  • Run apt update before your first apt install command in a new WSL session to refresh the list of available packages.
  • The basic syntax is apt install package-name, and you can install multiple packages in one command by listing them with spaces between.
  • You must use sudo (superuser do) before apt install because package installation requires administrator permissions.
  • If apt install fails, check that you have internet access, that the package name is spelled correctly, and that your package list is up to date.

Opening WSL and preparing apt for your first install

Open Windows Terminal or PowerShell and type wsl to enter your WSL environment. You will see a prompt that looks like user@computer:~$ or similar, which tells you that you are now inside Linux, not Windows.

Before you install anything, run sudo apt update. This command downloads the current list of packages available in Ubuntu's repositories. It does not install anything — it just refreshes your local copy of what is out there. You will see lines of text scrolling past as apt contacts the repositories. When it finishes, you will see your prompt again.

The first time you run a sudo command in a WSL session, you may be asked for your password. Type the password you set when you first installed WSL. Nothing will appear on screen as you type — that is normal and intentional for security. Press Enter when you are done.

The basic syntax for installing a single package

The simplest apt install command is sudo apt install package-name. Replace package-name with the actual name of what you want. For example, to install Git, you would type sudo apt install git. To install curl (a tool for downloading files from the command line), you would type sudo apt install curl.

After you press Enter, apt will tell you how much disk space the package and its dependencies will use, then ask you to confirm by typing y and pressing Enter. Dependencies are other packages that the thing you want needs to work — apt handles finding and installing those automatically, so you do not have to hunt them down yourself.

Once installation finishes, you will see your prompt again. The package is now ready to use. You can verify it worked by typing the package name followed by --version (for example, git --version) to see what version was installed.

Installing multiple packages at once

You can install several packages in a single command by listing them with spaces between. For example, sudo apt install git curl wget will install Git, curl, and wget (another read tool) all in one go. apt will resolve all the dependencies for all three packages, show you the total disk space needed, and ask for confirmation once.

This is faster than running three separate install commands because apt only needs to read and process the package list once. It is also useful when you are setting up a new development environment and know you will need several tools.

What to do if apt install fails or seems stuck

If you see an error like "E: Unable to locate package", the package name is either misspelled or does not exist in the repositories. Check the spelling carefully — package names are case-sensitive and often use hyphens instead of underscores. If you are not sure of the exact name, you can search using apt search keyword to find packages that match.

If apt install seems to hang or freeze, it is usually waiting for input. Check whether you missed a confirmation prompt — sometimes the text scrolls past quickly. Press y and Enter to confirm, or press Ctrl+C to cancel and start over.

If you see permission errors even though you used sudo, your WSL installation may have a configuration issue. Try running sudo apt update again to refresh the package list, then attempt the install again. If that does not work, you may need to restart WSL by closing Windows Terminal and opening it again.

If apt install fails because it cannot reach the repositories (you will see network-related error messages), check that your internet connection is working. WSL uses your Windows network connection, so if Windows cannot reach the internet, neither can WSL.

Understanding what apt install actually does on your system

When you run apt install, several things happen in sequence. First, apt downloads the package files from Ubuntu's repositories. Then it unpacks them into the correct directories on your WSL filesystem — binaries go to /usr/bin or /usr/local/bin, libraries go to /usr/lib, and configuration files go to /etc. Finally, apt runs any setup scripts the package includes.

All of this happens automatically. You do not need to move files around or edit configuration files yourself — apt handles the whole process. This is why using a package manager is so much faster than downloading and installing software manually.

The packages you install in WSL stay in WSL. They do not affect Windows or any other WSL distributions you might have installed. If you have both Ubuntu and Debian running in WSL, each one has its own separate set of installed packages.

Keeping your packages up to date

After you have installed packages, you can update them to newer versions using sudo apt upgrade. This command checks all your installed packages against the latest versions in the repositories and upgrades any that have updates available. Like apt install, it will show you what will be upgraded and ask for confirmation.

It is a good habit to run sudo apt update followed by sudo apt upgrade once a week or whenever you start a new development session. This keeps your tools and libraries current and ensures you have security patches.

Frequently Asked Questions

Do I always need to type sudo before apt install?

Yes. Installing packages requires administrator permissions, which is why sudo is required. Without it, apt will refuse to run and show a permission error. There is no way around this — it is a security feature to prevent accidental or malicious changes to your system.

What is the difference between apt install and apt-get install?

They do the same thing. apt is the newer, simpler interface to the same underlying system that apt-get uses. For WSL and modern Ubuntu, use apt. You will see apt-get in older documentation, but apt is preferred now.

Can I uninstall a package if I no longer need it?

Yes, using sudo apt remove package-name. This removes the package but leaves its configuration files in place. If you want to remove the configuration files too, use sudo apt purge package-name. You can also use sudo apt autoremove to clean up dependencies that are no longer needed by any installed package.

What happens if I install a package that conflicts with one I already have?

apt will detect the conflict and refuse to install. It will tell you which packages are incompatible and ask you to resolve the issue. Usually this means uninstalling one package before installing the other, or finding a different package that does what you need without the conflict.

Can I install packages from outside the official repositories?

Yes, but it requires adding a Personal Package Archive (PPA) or third-party repository first using sudo add-apt-repository, then running sudo apt update again. This is more advanced and should only be done if you trust the source. For most development work, the official repositories have everything you need.