Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the Linux software installation and package management tools

2025-01-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces "what are the Linux software installation and package management tools". In the daily operation, I believe many people have doubts about Linux software installation and package management tools. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "what are the Linux software installation and package management tools?" Next, please follow the editor to study!

0 preface

Generally speaking, there are three ways to install software in Linux systems: source code compilation installation, executable file (package) installation, and front-end tool dependent installation.

0.1 Source Code compilation and installation

The vast majority of open source software is released directly as source code, which is generally typed into a .tar.gz archive. After decompressing the compressed file, the obtained source code needs to be compiled into binary form before it can be run and used. Basic process of source code compilation:

. / configure check and build the compilation environment

Make compiles the source code, usually calls the Makefile file, reads instructions from it, and generates an executable file

Make test / make check checks the compilation in the previous step to make sure there are no errors (sometimes without this step)

Make install installs the generated executable file locally

The source code installation operation is complex, the compilation time is long, the problem is easy to occur, the dependency relationship is complex and needs to install the dependency manually.

0.2 package installation

Due to the inconvenient installation of the source code, the software package platform will compile the code into an executable file based on a specific platform system and save dependencies to simplify the installation and management of open source software. Different packages are set for different systems, such as dpkg software package for Debian and Ubuntu, RPM software package for Red Hat and CentOS and so on.

Although the package installation can run commands directly on the package, it still needs to download the package locally, and it is inconvenient to deal with the dependencies manually.

0.3 Front-end tool installation

In order to solve the problem of installation package and dependency of software package installation, the front-end tools are designed, such as yum is the front-end tool of rpm and apt-get is the front-end tool of dpkg. Front-end tools introduce the concept of repository (either local or remote) to manage software packages and automatically resolve dependencies during software installation.

1 Software package Management Package Management

Software package management system is a combination of tools for automatically installing, configuring, uninstalling and upgrading software packages in computers, which is widely used in the installation and management of all kinds of system software and application software.

In Linux distributions, almost every distribution has its own package management system. Common ones are:

Dpkg: the full name Debian Package, originally used by Debian and now used by Ubuntu (Note: Ubuntu originated from Debian and first appeared as a branch of Debian in 2004). Used to manage the .deb format package, it is the first package management tool with a well-known dependency on the solution tool APT. Aptitude, the front end for APT based on ncurses, is also a package manager for Debian-like systems.

RPM: the full name is Redhat Package Manager, created by Red Hat. RPM is the basic packaging format of the Linux standard and is the basis of a range of other tools, including apt4rpm, Red Hat's up2date, Mageia's urpmi, openSUSE's ZYpp (zypper), PLD Linux's poldek, Fedora's DNF and YUM (used by Red Hat Enterprise Linux and Yellow Dog Linux). In other words, these are its front ends.

Other software package management systems include Pacman,Gentoo used in ArchLinux, Homebrew under pkg,Mac under Portage,FreeBSD based on source code, and so on.

Using a package management system will greatly simplify the process of installing software in a Linux distribution.

2 dpkg2.1 dpkg (Debian Package)

Dpkg itself is a low-level tool that can install, move and build software packages, but unlike other package management systems, it can only be used to install local .deb files, cannot automatically download packages from remote package repositories and handle package dependencies, and does not care about the software in the software repository. The following are packages that use dpkg to manage local installations:

Lists all the software in the system package database, including all packages, installed and uninstalled, or you can use grep to specify some packages:

Dpkg-l | grep packageName

List the files installed by the software

Dpkg-L keyword

If you are not sure which package a file is installed by, dpkg-S will tell you:

Dpkg-S / etc/host.conf base-files: / etc/host.conf

The above example shows that / etc/host.conf belongs to the base-files package.

Be careful

Many files are generated automatically during package installation, and although they exist in the file system, dpkg-S may not know which package these files belong to.

Example of installing a local .deb file:

Sudo dpkg-I zip_3.0-4_amd64.deb

Example of uninstalling a package:

Sudo dpkg-r zip

Warning:

Using dpkg to uninstall packages is not recommended in most cases. A better approach is to use a package manager to deal with dependency issues to ensure that the system is in a continuously available state. For example, using dpkg-r zip will uninstall the zip package, but other installed software that depends on this package may not be available.

Use the man dpkg command to see more.

2.2 apt (Advanced Packaging Tool)

The apt command is a powerful command-line tool that performs operations such as installing new packages, updating existing packages, updating the package list index, and even updating the entire Ubuntu system. Apt-get will resolve and install module dependencies and query the software repository, but will not install local deb files. Apt is a software management tool based on dpkg. Here are some common methods

2.2.1 apt-get command # update sudo apt-get update update source sudo apt-get dist-upgrade upgrade system to the appropriate distribution (according to source.list configuration) sudo apt-get upgrade update installed package # install sudo apt-get install packageName1 [packageName2] installation package sudo apt-get install packageName-reinstall reinstallation package sudo apt-get-f install packageName repair installation sudo apt-get build- Compilation environment related to dep packageName installation # delete sudo apt-get remove packageName delete package sudo apt-get-purge remove packageName delete package Including configuration files, etc. # other apt-get check checks if there is any damage depending on sudo apt-get source packageName to download the source code of the package apt-get autoclean delete the deb package of the software you have deleted, apt-get clean delete all deb packages Including the installed package 2.2.2 apt-cache command sudo apt-cache search packageName search package sudo apt-cache show packageName to get information about the package, such as description, size, version, and so on. Sudo apt-cache showpkg packageName displays general information about the package sudo apt-cache depends packageName knows which packages the package depends on sudo apt-cache rdepends packageName to see which packages depend on 2.2.3 apt file / description of the var/lib/dpkg/available package, including installed and uninstalled packages on the current system. / etc/apt/sources.list records the address of the software source Modify this file to configure the software source / software packages that var/cache/apt/archives has downloaded are placed here (when apt-get install installs the software, the temporary storage path of the software package) / var/lib/apt/lists uses the apt-get update command to download the software list from / etc/apt/sources.list And all apt operations saved to this directory / var/log/dpkg.log will be saved to the file 2.2.4 apt-get update execution process

Execute apt-get update

Program analysis / etc/apt/sources.list and / etc/apt/sources.list.d

Automatically connect to the network to find the corresponding Packages/Sources/Release list file in list. If there is any update, download it and save it to the / var/lib/apt/lists/ directory.

Download and install the corresponding package for apt-get install.

2.2.5 apt-get intsall execution process

Scan the list of local software updates, that is, the / var/lib/apt/lists file saved during apt-get update

Package dependency check to find all packages that depend on the package that needs to be installed

Download the deb package from the mirror station in the software source

Extract the software package and automatically complete the installation and configuration of the software

2.2.6 modify software source / etc/apt/sources.list

Back up the original source.list file to facilitate rollback

Modify the sources.list file

Sudo apt-get update update source

2.2.7 the difference between apt-get update and apt-get upgrade

Apt-get update should be executed before apt-get upgrade. None of them automatically executes the other.

Apt-get update updates the list of available packages and versions. However, the software package is not installed or upgraded.

Apt-get upgrade will actually install updated versions of the packages you have. When you update the software list, the package manager knows which updates are available in the software you have installed, which is why you want to perform update in the first place.

Can jointly execute apt-get update & & apt-get upgrade

2.3 aptitude2.3.1 menu structure

Starting Aptitude without a command-line option will show a menu structure, a text-based front-end APT system. Many common package management methods, such as installing, uninstalling, and upgrading, can be executed with Aptitude plus a word that is usually lowercase.

Unlike apt-get, aptitude is better at dealing with dependencies. For example, when aptitude deletes a package, it also deletes the package on which it depends. In this way, useless packets will not be left in the system, and the whole system is cleaner.

Aptitude is most suitable for use in a non-image interface terminal environment, where you can enter:

Sudo aptitude

When Aptitude starts, you will see a menu bar at the top of the screen with two windows below. The above window includes package directories, such as new and uninstalled packages. The window below contains information about the package and the package road.

Using the Aptitude user interface for package management is simple:

Install software: use the keyboard arrow keys + ENTER keys to locate the software you want to install in the uninstalled package directory. When the package is highlighted, press the + key. At this point, the package will turn green, meaning it has been marked for installation. Pressing the g key at this time will show a summary of the actions of the software package. Press the g key again, and the download and installation of the package will begin. When you are finished, press ENTER to return to the menu.

Uninstall software: use the keyboard arrow keys + ENTER keys to locate the software you want to uninstall in the installed package directory. Press the-key when the package is highlighted. At this point, the package will turn pink, meaning it has been marked to be uninstalled. Pressing the g key at this time will show a summary of the actions of the software package. Press g again, and the uninstall of the package will begin. When you are finished, press ENTER to return to the menu.

Update the package index: press u key.

Update packages: do the above to update the package index, and then press the U key to mark all the packages you want to update. Pressing the g key at this time will show a summary of the actions of the software package. Press the g key again, and the download and installation of the package will begin. When you are finished, press ENTER to return to the menu.

The first column of package information is shown in the top window, and the following shortcuts are available when viewing the current package status:

I: installed software c: the package is not installed, but the package configuration file is still in the system p: v: virtual package B: broken package u: extracted files from the system, but the installation package is still not configured C: semi-configured: configuration failure needs to be resolved H: semi-installed: uninstall failure needs to be resolved

To exit Aptitude, press Q and confirm. Press F10 to view the details of the Aptitude menu.

2.3.2 Command Line

You can also use Aptitude as a command line tool, similar to apt.

Installation

Sudo aptitude install packageName

Unloading

The relationship between sudo aptitude remove packageName2.4 dpkg and apt

Both are the installation, uninstallation and other operations of .deb files.

Dpkg needs to manually download the .deb file to operate locally, while apt, as a front-end tool, gets the download directly from the remote repository.

Dpkg cannot handle dependency issues and needs to be manually installed one by one, while apt will be automatically processed and installed at one time.

3 RPM (Red Hat Package Manager)

Linux distributions often use dysfunctional package management tools, while Red Hat-based distributions use RPM (Red Hat Package Manager) and YUM/DNF (Yellow Dog Updater, Modified/Dandified YUM).

3.1 RMP (Red Hat Package Manager)

RPM is a popular package management tool in the basic release of Linux for Red Hat Enterprise Edition. You can use RPM to install, uninstall, and query software installation packages. Although RPM cannot manage package dependencies like YUM does, it still prompts for a list of packages required for installation. A RPM package consists of files and metadata archives, where the metadata includes help scripts, file properties, and package information.

RPM maintains a database of installed packages, which provides powerful and fast query capabilities. The RPM database is in the / var/lib directory, and the file is named _ _ db*.

RPM has many basic modes: query, validation, installation, upgrade, cleanup, display query tags, display configuration, and so on. To perform package management tasks, you must choose one of them. Each model has its own set of options. You can view it with the command man rpm. Here are some common patterns

Pattern description-I installation package-U upgrade package-e cleanup package-V verification package-Q query package

Here are some common options:

Select -? |-- help output help information-- version output version information-- v output redundancy information of the project

Command example

# install rpm-I package-file# upgrade rpm-U package-file# installation, output redundancy information, and use the # symbol (hash) to show the progress. See figure 1 rpm-ivh package-file# query, option a means query all (all) installed software packages, see figure 2 rpm-qa vim-enhanced# removal, see figure 3 rpm-evh vim-enhanced

Figure 1

Figure 2

Figure 3

3.2 Yellow Dog Updater, Modified (YUM) / Dandified yum (DNF)

[editor's note: DNF or Dandified YUM is the default package manager for updated Red Hat Enterprise Edition Linux 8, CentOS 8, Fedora 22 (and their based distributions). In general, the command options are the same. Here is a focus on YUM]

YUM is the primary software package management tool in Red Hat Enterprise Edition Linux, which is used to install, update, uninstall and manage software packages. YUM handles software dependencies when installing, updating, and uninstalling packages. YUM can be installed from installed repositories and .rpm packages in the system. The main configuration file for YUM is in the / etc/yum.conf file and all the repositories are in the / etc/yum.repos.d directory.

Command format

Yum-option command yum-option command

The following are common commands:

Command function yum install installation specified software package remove remove specified software package search searches for package metadata info enumeration description information update updates each package to the latest version of repolist list warehouse list history shows past operations and provides which commands were executed on which day

The following are common options:

Option feature-C runs from the system cache-security includes software packages that provide solutions to security problems-y answer all Yes/No questions Yes--skip-broken skips questions caused by the package-v shows redundant information

You can cancel and roll back certain operations by using the history command. The format is as follows:

Yum history undo

YUM provides many package management options, which can be viewed through man yum and yum-help. In addition, please refer to the documentation.

3.3.The relationship between RPM and YUM

Both RPM and YUM can manage the .rpm package.

RPM needs to download the .rpm installation package locally before it can be installed, while YUM only needs to specify the name of the software to be installed, and it will automatically download and install from the specified server.

When you encounter dependency problems, RPM needs to manually download and install them one by one, while YUM automatically handles dependencies and installs all dependent software packages at once.

At this point, the study on "what are the Linux software installation and package management tools" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report