APT Commands
Complete reference for APT package management inside the Ubuntu proot environment. For background on how package managers work, see What is a Package Manager.
When running inside proot-distro, you are already root. All apt commands run directly without sudo. If you are accessing the environment from an outer shell or script that does not enter proot as root, prefix commands with sudo as usual.
Installing Packagesโ
| Command | Description | Example |
|---|---|---|
apt install <pkg> | Install a package and its dependencies | apt install vim |
apt install -y <pkg> | Install without confirmation prompt | apt install -y curl wget |
apt install <pkg1> <pkg2> | Install multiple packages at once | apt install git nodejs npm |
apt install --no-install-recommends <pkg> | Install without recommended extras (smaller footprint) | apt install --no-install-recommends python3 |
apt install <pkg>=<version> | Install a specific version | apt install nodejs=18.19.0-1nodesource1 |
apt reinstall <pkg> | Reinstall a currently installed package | apt reinstall openssh-client |
dpkg -i <file>.deb | Install a local .deb file | dpkg -i package.deb |
apt install -y build-essentialIf dpkg -i fails due to missing dependencies, run:
apt install --fix-broken -yThis resolves and installs any missing dependencies for the partially installed package.
Removing Packagesโ
| Command | Description | Example |
|---|---|---|
apt remove <pkg> | Remove a package but keep its configuration files | apt remove apache2 |
apt purge <pkg> | Remove a package and its configuration files | apt purge apache2 |
apt remove --purge <pkg> | Same as apt purge | apt remove --purge nginx |
apt autoremove | Remove packages that were installed as dependencies and are no longer needed | apt autoremove |
apt autoremove --purge | Autoremove and delete configuration files | apt autoremove --purge |
apt autoremove -yapt purge deletes configuration files in /etc that belong to the package. If you have customized config files, back them up before purging.
Updating & Upgradingโ
| Command | Description | Example |
|---|---|---|
apt update | Refresh the package index from repositories | apt update |
apt upgrade | Upgrade all installed packages to their latest versions (safe, no removals) | apt upgrade -y |
apt full-upgrade | Upgrade packages, adding or removing dependencies as needed | apt full-upgrade -y |
apt dist-upgrade | Same as full-upgrade; handles changing dependencies intelligently | apt dist-upgrade -y |
Always run apt update before apt install or apt upgrade to ensure you are pulling from the latest package index.
apt update && apt upgrade -ySearching & Informationโ
| Command | Description | Example |
|---|---|---|
apt search <term> | Search package names and descriptions | apt search image editor |
apt show <pkg> | Display detailed information about a package | apt show ffmpeg |
apt list | List all available packages | apt list |
apt list --installed | List only installed packages | apt list --installed |
apt list --upgradable | List packages with available upgrades | apt list --upgradable |
dpkg -l | List all installed packages with version and status | dpkg -l |
dpkg -l <pattern> | Filter installed packages by name pattern | dpkg -l 'lib*' |
dpkg -L <pkg> | List all files installed by a package | dpkg -L coreutils |
apt list --installed 2>/dev/null | grep -i pythonPipe dpkg -l or apt list through grep to quickly filter results when searching for a specific package.
Cache Managementโ
| Command | Description | Example |
|---|---|---|
apt clean | Delete all cached .deb files from /var/cache/apt/archives | apt clean |
apt autoclean | Delete only cached .deb files that can no longer be downloaded (obsolete) | apt autoclean |
apt-cache stats | Show cache statistics (total packages, versions, dependencies) | apt-cache stats |
apt-cache policy <pkg> | Show installed and candidate versions plus repository priority | apt-cache policy nodejs |
apt clean && apt autocleanIn a proot environment, disk space is shared with the Android host. Running apt clean after large installs helps reclaim storage.
Common Flagsโ
| Flag | Long Form | Description |
|---|---|---|
-y | --yes | Assume "yes" to all prompts; run non-interactively |
--no-install-recommends | Skip recommended (but not required) packages | |
-f | --fix-broken | Attempt to fix broken dependencies |
-s | --dry-run | Simulate the operation without making changes |
--allow-downgrades | Allow installing an older version of an already-installed package | |
-q | --quiet | Suppress progress output; useful in scripts |
-d | --download-only | Download packages but do not install them |