4. Essential Initial Commands: Updating and Upgrading
Before installing any new software, the first and most critical step is to update and upgrade your package list and installed packages. Termux uses the pkg command, which is a wrapper around the Debian apt utility.
1. Updating the Package List (pkg update)
This command downloads the latest package lists from the Termux repositories. It tells Termux what packages are available and what versions they are.
bash $ pkg update
Always run this before installing new software.
2. Upgrading Installed Packages (pkg upgrade)
This command upgrades all currently installed packages to their newest available versions based on the updated package list.
bash $ pkg upgrade
When prompted (e.g., "Do you want to continue? [Y/n]"), always type Y and press Enter.
Note on Configuration Files: During the upgrade, you might be asked about maintaining or replacing configuration files (e.g., Configuration file '/etc/bash.bashrc' ... Install the package maintainer's version? [Y/n/D/Z]). For beginners, it is usually safe to choose the default option (N or press Enter) to keep your existing configuration, unless specifically instructed otherwise.
Combined Best Practice
It is common practice to run both commands sequentially when setting up a fresh session or after a long period of inactivity:
bash $ pkg update && pkg upgrade
The && operator ensures that pkg upgrade only runs if pkg update was successful.