ดู help ของคำสั่ง apt
$ apt --help apt 2.4.8 (amd64) Usage: apt [options] command apt is a commandline package manager and provides commands for searching and managing as well as querying information about packages. It provides the same functionality as the specialized APT tools, like apt-get and apt-cache, but enables options more suitable for interactive use by default. Most used commands: list - list packages based on package names search - search in package descriptions show - show package details install - install packages reinstall - reinstall packages remove - remove packages autoremove - Remove automatically all unused packages update - update list of available packages upgrade - upgrade the system by installing/upgrading packages full-upgrade - upgrade the system by removing/installing/upgrading packages edit-sources - edit the source information file satisfy - satisfy dependency strings See apt(8) for more information about the available commands. Configuration options and syntax is detailed in apt.conf(5). Information about how to configure sources can be found in sources.list(5). Package and version choices can be expressed via apt_preferences(5). Security details are available in apt-secure(8). This APT has Super Cow Powers.
Update and Upgrade packages
update list of available packages
$ sudo apt update
list packages ที่สามารถอัพเกรดได้
$ apt list --upgradable
upgrade the system by installing/upgrading packages
$ sudo apt upgrade
ทำคำสั่ง apt update และต่อด้วย apt upgrade ด้วยการใช้คำสั่ง &&
When using the && command, the second command will be executed only when the first one has been succcefully executed.
$ sudo apt update && sudo apt upgrade
Install or Remove package
install packages
$ sudo apt install <package_name>
remove packages
$ sudo apt remove <package_name>
Remove automatically all unused packages
$ sudo apt autoremove
reinstall packages
sudo apt reinstall <package_name> sudo apt reinstall lighttpd
hold a package ด้วย apt-mark
sudo apt-mark hold <package_name> sudo apt-mark hold sudo
unhold a package ด้วย apt-mark
sudo apt-mark unhold <package_name> sudo apt-mark unhold sudo
Other
show package details
To show or see information about the given package(s) including its dependencies, installation and download size, sources the package is available from, the description of the packages content and much more:
$ apt show <package_name> $ apt show sudo
List package dependency
apt depends <package_name> apt depends sudo
search in package descriptions
apt search php apt search mysql-5.? apt search mysql-server-5.? apt search httpd* apt search ^apache apt search ^nginx apt search ^nginx$
apt search ค้นหาใน package descriptions ทำให้ได้ข้อมูลเยอะเกิน หา pakcage ที่ต้องการยาก ให้ลองใช้ apt list แทน
apt list apt list | more apt list | grep foo apt list | grep php7- apt list nginx apt list 'php7*'
List all installed packages
apt list --installed apt list --installed | grep <package_name>
Ref