Chapter 14: Package Management in WSL Ubuntu
Package management is a key skill in Linux. WSL Ubuntu uses apt (Advanced Package Tool) to install, update, and remove software efficiently. Understanding package management keeps your system up-to-date and secure.
In this chapter, you’ll learn essential apt commands, how to search for packages, install software, update your system, and remove unnecessary packages.
๐ Updating the Package Index
sudo apt update
Refreshes the package list from repositories to ensure you install the latest versions.
๐ Upgrading Installed Packages
sudo apt upgrade
Upgrades all installed packages to the latest available versions.
๐ Installing Packages
sudo apt install package-name
Example:
sudo apt install git
๐ Removing Packages
sudo apt remove package-name
Removes the package but keeps configuration files.
sudo apt purge package-name
Removes the package along with configuration files.
๐ Searching for Packages
apt search package-name
Helps you find available software packages in repositories.
๐ Cleaning Up Unused Packages
sudo apt autoremove
sudo apt clean
Frees disk space by removing unnecessary packages and cached files.
๐ Managing Repositories
sudo add-apt-repository ppa:repository-name
sudo apt update
Adds external repositories to access additional software.
๐งช Practice Exercises
# Update package index
sudo apt update
# Upgrade all packages
sudo apt upgrade
# Install Git
sudo apt install git
# Remove a package
sudo apt remove nano
# Purge a package
sudo apt purge nano
# Search for a package
apt search python3
# Clean up unused packages
sudo apt autoremove
sudo apt clean
โ Summary
sudo apt updateโ Refresh package listsudo apt upgradeโ Upgrade installed packagessudo apt installโ Install softwaresudo apt remove / purgeโ Remove softwareapt searchโ Search for packages- Use
autoremoveandcleanto free space - Add repositories to install additional software
โถ๏ธ Coming Up Next
Chapter 15 โ Shell Scripting Basics in WSL Ubuntu
Learn how to automate tasks, write simple scripts, and use variables, loops, and conditionals in Bash shell scripting.
