Home > Article > Operation and Maintenance > what is linux apt
APT is a software package management tool under Linux systems that can automatically download, configure, and install software packages in binary or source code format; most apt commands must be run as a user with sudo permissions. APT was first designed as the front end of dpkg, used to process deb format software packages; now after modification by the APT-RPM organization, APT can be installed on systems that support RPM to manage RPM packages.
The operating environment of this tutorial: Ubuntu 21.04 system, Dell G3 computer.
If we want to install a certain software through the Linux command line, just enter the following command directly at the command line:
sudo apt-get update sudo apt-get install
This installation method is through the apt tool To achieve installation, what exactly is apt?
The full name of APTAdvanced Packaging Tool , that is, Advanced Packaging Tool, is a software package management tool under the Linux system. APT simplifies the process of managing software on Unix systems by automatically downloading, configuring, and installing software packages in binary or source code format. Apt can be used to:
Install the application
Remove the application
Keep the application as The latest
There are more functions...
APT was first designed as the front end of dpkg (Debian Package), used to process deb format software package. Now after modification by the APT-RPM organization, APT can be installed to manage RPM packages on systems that support RPM. This package manager contains multiple tools starting with apt-, such as apt-get apt-cache apt-cdrom etc.
In simple terms, APT is a command line utility , for # installation, update, management, delete, finding ... . Most apt commands must be run as a user with sudo permissions .
APT is aclient/server system. First copy all deb packages on the server (deb - file extension of Debian software package format); then use APT's analysis tool - genbasedir to analyze all deb packages based on the header information of each deb package, and analyze The results are recorded in a file - DEB Index List. The DEB index list of APT servers is placed in the base folder. Once the deb package in the APT server is changed, be sure to use genbasedir to generate a new DEB index list. When installing or upgrading, the client must first query the DEB index list to obtain all software packages with dependencies, and download them to the client together for installation.
When the client needs to install, upgrade or delete a software package, the client computer obtains the compressed file of the DEB index list, decompresses it and places it in the /var/state/apt/lists/ directory. When the client uses the apt-get install or apt-get upgrade command, the data in this folder will be compared with the DEB database in the client computer to know which DEBs are installed, not installed, or can be upgraded. of.
The client needs to regularly download a package list from the server, because the apt tool is actually available packages Work on the database. When performing an installation operation, the apt-get tool will search for relevant information about the target software in the available software package database of the local
Download the software on the server and install it. Therefore, before installation, you usually update the local software package database through ### sudo apt-get update ###. #########3. APT commands############ (1) apt-get common commands######
Command | Description |
---|---|
##sudo apt-get update | UpdateLocal packageDatabase |
install | Installsoftware package |
| software package, such as: the system is damaged , some incorrect configurations cause the software to not work properly...|
Upgrade | All installed packages##sudo apt-get |
Full UpgradeInstalled software package | ##sudo apt-get | remove
RemoveInstalled software packages (including software packages that have dependencies on the removed software package, but do not include the configuration file of the software package) | sudo apt-get | autoremove
RemoveBefore dependent on other software packages, but now no longer used Software package | sudo apt-get | purge
Completely remove the package (including the package's configuration file | )##sudo apt-get clean |
RemoveThe installed software package downloaded to the local area is saved in /var/cache/apt/archives/ | ## by default.#sudo apt-get list |
list | sudo apt-get search |
##Searchsoftware package | sudo apt-getshow |
Display package specific information, such as : Version number, installation size, dependencies, etc. | (2) apt-get common parameters |
ParameterDescription
##-y | |
---|---|
-s | |
-q | |
q or | -q=# (# represents a number, used for setting Silent level), very useful when you don’t want too much screen output during the installation process-f | ##Fix
-d | Download only |
--reinstall | ##Reinstall | Already installed but there may be problems Software package
--install-suggests | Also install the suggested installation## given by APT #’s software package |
四、使用 apt 命令管理基于 Debian 和 Ubuntu 的 Linux 发行版中的包我在本教程中使用 Ubuntu 21.04,但你可以使用任何其他基于 Debian/Ubuntu 的 Linux 发行版,例如 Linux Mint、elementary OS、Linux Lite 等。 apt 作用于可用包的数据库。如果数据库没有更新,系统将不知道是否有可更新的软件包可用。这就是为什么在任何 Linux 系统中进行了全新安装后,首先要更新存储库。 更新包数据库需要超级用户权限,因此您需要使用sudo。 sudo apt update 运行此命令看到从各种服务器检索的包信息:
更新软件包数据库后,就可以升级已安装的软件包。最方便的方法是升级所有具有可用更新的软件包。可以简单地使用以下命令: sudo apt upgrade 这将显示将要升级的所有软件包的数量和种类。 还有另一种方法可以使用以下命令提供完整升级: sudo apt full-upgrade
4.3、apt update 和 apt upgrade 的区别 虽然听起来像当执行 例如,如果你安装了 XYZ 包 1.3 版,则在 apt 更新后,数据库将知道有更新的 1.4 版可用。当你在 apt update 之后执行 apt upgrade 时,它会将已安装的软件包升级(或更新)到较新的版本。 这就是为什么使用此命令更新 Ubuntu 系统最快、最方便的原因: sudo apt update && sudo apt upgrade -y 如果已经知道包的名称,则可以使用以下命令进行安装: sudo apt install <package_name></package_name> 只需将 sudo apt install mplayer 可以使用自动完成功能。当不确定确切的包名称时,可以输入几个字母并按Tab,它会建议所有以这些字母开头的可用的包。例如: 注意是按Tab,而不是Enter! 使用自动完成功能查找具有给定名称的包: 不必一次只安装一个软件包。可以通过同时提供多个软件包名称来一次安装多个软件包: sudo apt install <package_1> <package_2> <package_3></package_3></package_2></package_1> 4.6、如果在已安装的软件包上运行 apt install 会怎样 这将只查看数据库,如果找到更新的版本,它会将已安装的软件包升级到较新的软件包。因此,使用它不会造成任何伤害,除非你不希望它升级。 如果由于某种原因你想安装一个包,但不想升级,如果它已经安装了。在这种情况下,你可以通过以下方式使用选项 sudo apt install <package_name> --no-upgrade</package_name> 如果你只想升级软件包但不想安装它(如果尚未安装),则可以使用以下命令执行此操作: sudo apt install <package_name> --only-upgrade</package_name> 默认情况下,将为应用程序安装存储库中可用的最新版本。但是如果不想安装最新版本,可以指定版本号。你需要知道要安装的确切版本号。 只需在包名称后添加 sudo apt install <package_name>=<version_number></version_number></package_name> 删除软件包就像安装它们一样简单。只需使用以下命令: sudo apt remove <package_name></package_name>
sudo apt purge <package_name></package_name> apt remove 和 apt purge 的区别
如果你习惯于 当你弄乱了程序的配置,你想从系统中完全清除它的痕迹再重新开始,清除会很有用。也可以在已删除的包上使用 通常, 这不是搜索包的最好方式。但是当你在寻找一些特定的库时,这很有用。只需将以下命令与所需的搜索词一起使用,就可以找到包含搜索词的所有包。 apt search <search></search> 如果你想在安装或删除软件包之前了解有关软件包的更多信息,可以使用以下命令: apt show <package_name></package_name> 这将显示有关给定包的信息,例如其依赖项、安装和下载大小、包的不同来源、包内容的描述等: apt 命令有一个名为 list 的新选项。使用此命令,可以查看所有准备升级的较新版本的软件包: apt list --upgradable
apt list --installed 还有第三个选项,称为 apt list --all-versions 与 apt-get 不同,这里没有 clean 和 autoclean 命令。但是仍然可以使用 sudo apt autoremove 安装软件时会自动安装一些满足依赖关系的库和包。如果软件包被删除,这些自动安装的库和包虽然没有用,但仍会保留在系统中。可以使用此命令清除掉。 相关推荐:《Linux视频教程》 |
The above is the detailed content of what is linux apt. For more information, please follow other related articles on the PHP Chinese website!