Home  >  Article  >  System Tutorial  >  Master APT and easily manage Linux software

Master APT and easily manage Linux software

PHPz
PHPzforward
2024-02-10 23:54:15463browse

As a Linux system administrator, you have to face numerous software installation and update tasks every day. APT (Advanced Packaging Tool) is a powerful software package management tool that simplifies our software management process on Linux and ensures that we can manage the system quickly and efficiently. This article will introduce you to the functions and usage of APT, allowing you to easily manage all software on Linux.

Master APT and easily manage Linux software

The package manager can help you deal with issues such as updating, uninstalling, and troubleshooting software on Linux computers. Seth Kenlon wrote the article Using dnf for Linux package management, which introduces how to use dnf, a command-line package management tool, to install software in Linux distributions such as RHEL, CentOS, Fedora, Mageia, OpenMandriva, etc.

Debian and Debian-based distributions (such as MX Linux, Deepin, Ubuntu) and Ubuntu-based distributions (such as Linux Mint and Pop!_OS) have apt, a "similar but different" tool. In this article, I'll show you how to use it, following Seth's example (but using apt).

At the beginning, I would like to mention four software installation tools related to apt:

Synaptic​​​ is a GTK-based graphical user interface (GUI) front-end tool for ​​apt​​. ​​Aptitude​​​ is an Ncurses-based full-screen command line front-end tool for ​​apt​​. The predecessors of apt include apt-get, apt-cache and other tools. ​​Dpkg​​​ is the "behind-the-scenes worker" that handles complex affairs behind the ​​apt​​ package manager.

There are other package management systems, such as Flatpak and Snap, that you may encounter on Debian and Debian-based systems, but I'm not going to discuss them here. There are also application "stores", such as GNOME "Software", that overlap with apt and other packaging technologies; I'm not going to discuss them here either. Finally, there are other Linux distributions such as Arch and Gentoo that use neither dnf nor apt, and I'm not going to discuss them here!

I have talked about so much above that I don’t want to mention. You may wonder how much software apt can handle. Let's put it this way, on my Ubuntu 20.04, apt allows me to use 69,371 packages, from 0ad (an ancient war-themed real-time strategy game) to zzuf (a transparent application fuzzing tool), not at all Difference.

Use apt to search software

The first step in using the apt package manager is to find the package of interest. Seth's dnf article uses the Cockpit server management application as an example. With apt I would enter the following command:

$ apt search cockpit
Sorting... Done
Full Text Search... Done
389-ds/hirsute,hirsute 1.4.4.11-1 all
  389 Directory Server suite - metapackage

cockpit/hirsute,hirsute 238-1 all
  Web Console for Linux servers

...
$

The second package above is the one you want (the line starting with cockpit/hirsute). If you decide to install it, enter:

$ sudo apt install cockpit

apt will take care of installing Cockpit and any components or dependencies required to make it work. Sometimes we're not quite sure this is what we need. Knowing more may help you decide whether you really want to install this application.

Package metadata

To learn more about a package, use the apt show command:

$ apt show cockpit
Package: cockpit
Version: 238-1
Priority: optional
Section: universe/admin
Origin: Ubuntu
Maintainer: Ubuntu Developers 
Original-Maintainer: Utopia Maintenance Team 
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 88.1 kB
Depends: cockpit-bridge (>= 238-1), cockpit-ws (>= 238-1), cockpit-system (>= 238-1)
Recommends: cockpit-storaged (>= 238-1), cockpit-networkmanager (>= 238-1), cockpit-packagekit (>= 238-1)
Suggests: cockpit-doc (>= 238-1), cockpit-pcp (>= 238-1), cockpit-machines (>= 238-1), xdg-utils
Homepage: https://cockpit-project.org/
Download-Size: 21.3 kB
APT-Sources: http://ca.archive.ubuntu.com/ubuntu hirsute/universe amd64 Packages
Description: Web Console for Linux servers
 The Cockpit Web Console enables users to administer GNU/Linux servers using a
 web browser.
 .
 It offers network configuration, log inspection, diagnostic reports, SELinux
 troubleshooting, interactive command-line sessions, and more.

$

Pay special attention to the Description field, which will tell you more information about the application. The Depends field describes what else must be installed, while Recommends shows what other (if any) partner components are recommended for installation. The Homepage field provides a URL where you can learn more.

Which package provides this file?

Sometimes you don’t know the package name, but you know that the package must contain a certain file. Seth uses the qmake-qt5 program as an example. Can't find it using apt search:

$ apt search qmake-qt5
Sorting... Done
Full Text Search... Done
$

However, another related command, apt-file, can be used to explore the inside of the package:

$ apt-file search qmake-qt5
qt5-qmake-bin: /usr/share/man/man1/qmake-qt5.1.gz
$

A qmake-qt5 man page will be displayed. It is part of a package called qt5-qmake-bin. Note that this package name reverses the order of the strings qmake and qt5.

What files are included in the package?

The convenient apt-file command lists which files are included in a given package. For example:

$ apt-file list cockpit
cockpit: /usr/share/doc/cockpit/TODO.Debian
cockpit: /usr/share/doc/cockpit/changelog.Debian.gz
cockpit: /usr/share/doc/cockpit/copyright
cockpit: /usr/share/man/man1/cockpit.1.gz
cockpit: /usr/share/metainfo/cockpit.appdata.xml
cockpit: /usr/share/pixmaps/cockpit.png
$

Note that this is different from the information provided by the apt show command, which lists the package's dependencies (other packages that must be installed).

Remove an application

You can also use apt to remove packages. For example, to remove the apt-file application:

$ sudo apt purge apt-file

Note that apt must be run by superuser to install or remove applications.

Removing a package does not automatically remove all dependencies installed by apt in the process. However, these residues are easily removed with a little work:

$ sudo apt autoremove

Get to know apt

As Seth writes, "The more you know about how a package manager works, the easier it will be when you need to install and query applications."

Even if you are not a heavy apt user, there are some apt tips to know when you need to install or remove packages from the command line (for example, on a remote server or following some kindly published how-to guide) Knowledge will also be useful. In the case where some software creators only provide a bare .pkg file, some knowledge about dpkg (as mentioned above) may also be required.

I find the Synaptic package manager to be a very useful tool on my desktop, but I also use apt on a handful of servers I maintain for various purposes.

Managing software on Linux can get very complicated, but APT can help us overcome these challenges. Mastering the use of APT can effectively improve our production efficiency and ensure the safety and stability of the system. I hope this article can help you better understand APT and provide you with strong support for software package management on Linux systems.

The above is the detailed content of Master APT and easily manage Linux software. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:lxlinux.net. If there is any infringement, please contact admin@php.cn delete