5. Apt update software source¶
‘apt’ is a command line utility for installing, updating, removing and managing deb packages on Ubuntu, Debian and related Linux distributions.
The software and commands we usually use can be downloaded from apt and used
5.1. Update and upgrade¶
It is important to keep your LubanCat up to date. The first and probably most important reason is security. Devices running the Linux operating system depend on millions of lines of code. Over time, these millions of lines of code will expose well-known vulnerabilities that are documented in publicly available databases, meaning they can be easily exploited.
In addition, some software will also rely on the latest software packages, updates and upgrades can also be compatible with more software
注解
When we burn a new image or encounter some software that cannot be installed, we recommend using apt to update and upgrade.
注意
When using the ‘apt’ command, you need to connect to the network
1 2 3 4 5 | #Update package database
sudo apt update
#Upgrade installed packages
sudo apt upgrade
|
注意
If an update error is encountered during the upgrade, we re-execute the command.
As shown below:

If the above situation occurs during the update, it means that the system time is incorrect and the network acquisition time has not been successful.
Solution:
Wait a while for the network to update the clock.
Use the command date -s + the time of day (manually set the time)
5.2. Modify the apt software source¶
The LubanCat series boards use the software source of the University of Science and Technology of China before leaving the factory. If you want to replace the software source yourself, it is recommended to choose a smooth domestic software source.
The following software sources are recommended here:
ubuntu20.04 software sources: http://t.zoukankan.com/leeyazhou-p-12976814.html
debian 10 software sources: https://www.jianshu.com/p/b4a792945d99
Before rewriting the software source, you can back up the software source to prevent setting the wrong software source.
1 2 3 4 5 6 7 8 9 10 11 | #Backup software source
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
#Edit the software sources you want to use
sudo vi /etc/apt/sources.list
#Update software source
sudo apt update
#Upgrade
sudo apt upgrade
|
Modify the software source and return to the software source of the University of Science and Technology of China.
1 2 3 4 5 6 7 8 | #Modify the software source to the Chinese University of Science and Technology software source.
sudo cp /etc/apt/sources.list.backup /etc/apt/sources.list
#Update software source
sudo apt update
#Upgrade
sudo apt upgrade
|
5.3. apt common commands¶
5.3.1. Update package database with ‘apt’¶
apt actually works on the database of available packages. If the database is not updated, the system will not know if a newer package is available. That’s why after installing any Linux system, the first thing you should do is update the apt database.
1 | sudo apt update
|
When you run this command, you will see package information retrieved from various servers.
5.3.2. Upgrade installed packages using apt¶
After the package database is updated, installed packages can be upgraded. The most convenient way is to upgrade all packages for which updates are available
1 | sudo apt upgrade
|
5.3.3. Install packages using apt¶
1 2 3 4 5 6 7 8 9 10 11 12 13 | sudo apt install package_name
#If for some reason you want to install a package, but not upgrade, then you don't have to upgrade if it's already installed.
sudo apt install <package_name> --no-upgrade
#If you just want to upgrade a package, but not install it (if it isn't already installed), you can do it with the command
sudo apt install <package_name> --only-upgrade
#Install specific versions 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 name of the package.
sudo apt install <package_name>=<version_number>
|
5.3.4. Remove packages using apt¶
To remove installed packages
1 2 3 4 | sudo apt remove package_name
#You can also specify multiple packages, separated by spaces.
sudo apt remove package1 package2
|
The remove command will uninstall the given package, but may leave some configuration files behind. If you want to remove a package with all configuration files, please use purge instead of remove
1 | sudo apt purge
|
5.3.5. Use apt to remove unused packages¶
Package dependencies are also installed whenever a new package that depends on other packages is installed on the system. Dependencies will remain on the system after the package is removed. These remaining packages are no longer used by anything else and can be removed
1 | sudo apt autoremove
|
5.3.6. Generate a package list with apt¶
The list command allows you to list available, installed and upgradable packages
1 2 3 4 5 6 7 8 9 | sudo apt list
#The command will output a list of all packages, including information about the package's version and architecture. To find out if a particular package is installed, you can use the grep command to filter the output
sudo apt list | grep package_name
#To list only installed packages
sudo apt list --installed
#Before actually upgrading packages, it might be useful to get a list of upgradable packages
sudo apt list --upgradeable
|
5.3.7. Search for packages with apt¶
This command allows you to search for a given package in the list of available packages
1 | sudo apt search package_name
|
5.3.8. Use apt to display package information¶
Information about package dependencies, installation size, package sources, etc. may be useful before removing or installing a new package.
1 | sudo apt show package_name
|
5.3.9. Clean archive of downloaded files with apt¶
1 | sudo apt-get clean
|
5.3.10. Use apt to download software source code¶
1 | sudo apt-get source <packages>
|
5.3.11. Learn about software dependencies with apt¶
1 | sudo apt-cache depends <packages>
|
5.3.12. Check software dependencies with apt¶
1 | sudo apt-get check
|