Understanding the Error
E: Unable to locate package packagename
Fix 1: Update Package Lists
sudo apt update
sudo apt install packagename
Fix 2: Check Package Name Spelling
# Search for package
apt search keyword
apt-cache search keyword
# Exact name search
apt list *keyword*
apt-cache pkgnames | grep keyword
Fix 3: Enable Universe/Multiverse Repos
# Ubuntu
sudo add-apt-repository universe
sudo add-apt-repository multiverse
sudo apt update
Fix 4: Check Architecture
dpkg --print-architecture
# Some packages only for amd64
Fix 5: Add Third-Party PPA
# Example: Add PHP repository
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php8.2
Fix 6: Use Aptitude (Better Search)
sudo apt install aptitude -y
aptitude search packagename
Fix 7: Check /etc/apt/sources.list
cat /etc/apt/sources.list
# Ensure not commented out
# May need to uncomment or add sources
Fix 8: Download .deb Manually
# For non-apt packages
wget https://example.com/package.deb
sudo dpkg -i package.deb
sudo apt install -f # Fix dependencies