05 Software Update
apt is a command-line utility used to install, update, delete, and manage deb packages on Ubuntu, Debian, and related Linux distributions.
The software and commands we usually use can be downloaded from apt.
1 Update and Upgrade
Devices running the Linux operating system rely on millions of lines of code. Over time, these millions of lines of code will expose known vulnerabilities, which are recorded in publicly available databases, meaning they are easily exploited.
In addition, some software also relies on the latest software packages, and updates and upgrades can also be compatible with more software.
Tips
When we flash a new image or encounter some software that cannot be installed, we recommend using apt for updates and upgrades.
Warning
The apt command requires a network connection when used.
# Update package database
sudo apt update
# Upgrade installed packages
sudo apt upgrade2 Modify apt Source
The board uses the USTC (University of Science and Technology of China) software source by default. If you want to change the software source yourself, it is recommended to choose a smooth domestic software source.
Before rewriting the software source, you can back up the software source to prevent setting the wrong software source.
# Backup software source
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
# Edit the software source you want to use
sudo vi /etc/apt/sources.list
# Update software source
sudo apt update
# Upgrade
sudo apt upgradeModify the software source back to USTC:
# Modify the software source to USTC software source
sudo cp /etc/apt/sources.list.backup /etc/apt/sources.list
# Update software source
sudo apt update
# Upgrade
sudo apt upgrade3 Common apt Commands
3.1 Update Package Database using apt
apt actually works on a database of available packages. If the database is not updated, the system will not know if updated packages are available. That is why the first thing after installing any Linux system should be to update the apt database.
sudo apt updateWhen running this command, you will see package information retrieved from various servers.
3.2 Install Packages using apt
sudo apt install package_name
# If for some reason you want to install a package but not upgrade it if it is already installed:
sudo apt install <package_name> --no-upgrade
# If you only want to upgrade a package but not install it (if not already installed):
sudo apt install <package_name> --only-upgrade
# Install a specific version of software using apt
# By default, the latest version available in the repository will be installed for the application.
# But if you don't want to install the latest version, you can specify the version number.
# You need to know the exact version number to install - just add =version with the package name.
sudo apt install <package_name>=<version_number>3.3 Remove Packages using apt
Information about package dependencies, installation size, package source, etc. may be useful before removing or installing new packages.
sudo apt show package_name3.4 Clean Downloaded File Archives using apt
sudo apt-get clean3.5 Download Software Source Code using apt
sudo apt-get source <packages>3.6 Understand Software Dependencies using apt
sudo apt-cache depends <packages>3.7 Check Software Dependencies using apt
sudo apt-get check