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

Example Analysis of Software package Management in Linux

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly introduces the example analysis of software package management in Linux, which is very detailed and has certain reference value. Friends who are interested must finish it!

1. Rpm RPM package manager

The option-Q indicates that the software package installed by the query system

[root@centos7 ~] # rpm-Q sudo sudo-1.8.6p7-16.el7.x86_64 [root@centos7 ~] # rpm-Q nginx does not install the software package nginx [root@centos7 ~] #

Option-a means to query all installed rpm packages

[root@centos7 ~] # rpm-qa | grep vim vim-filesystem-7.4.160-1.el7.x86_64 vim-common-7.4.160-1.el7.x86_64 vim-enhanced-7.4.160-1.el7.x86_64 vim-minimal-7.4.160-1.el7.x86_64 [root@centos7 ~] #

The option-f file indicates the software package to which the query file belongs

[root@centos7 ~] # rpm-qf / usr/bin/ls coreutils-8.22-15.el7.x86_64 [root@centos7 ~] #

Option-c indicates the configuration file of the query package

[root@centos7 ~] # rpm-qc sudo / etc/pam.d/sudo / etc/pam.d/sudo-i / etc/sudo-ldap.conf / etc/sudo.conf / etc/sudoers [root@centos7 ~] #

Option-e means to uninstall the package

[root@centos7 ~] # rpm-e sudo warning: / etc/sudoers has been saved as / etc/sudoers.rpmsave [root@centos7 ~] # rpm-Q sudo has not installed the package sudo [root@centos7 ~] #

Option-I for installation-v for display details-h for installation progress

# download rpm package [root@centos7 tmp] # wget ftp.scientificlinux.org/linux/scientific/7rolling/x86_64/os/Packages/sudo-1.8.6p7-16.el7.x86_64.rpm # install [root@centos7 tmp] # rpm-ivh sudo-1.8.6p7-16.el7.x86_64.rpm warning: sudo-1.8.6p7-16.el7.x86_64.rpm: header V4 DSA/SHA1 Signature Key ID 192a7d7d: NOKEY preparing. # # [100%] upgrading / installing... 1:sudo-1.8.6p7-16.el7 # # [100%]

There is a lot of software that does not have only one rpm package. There are various dependencies between them. When installing (or uninstalling), all dependent packages need to be installed (or uninstalled) before they can be installed (or uninstalled) successfully.

[root@centos7 tmp] # rpm-e vim-common error: dependency detection failed: vim-common = 2vim-common 7.4.160-1.el7 is (installed) vim-enhanced-2:7.4.160-1.el7.x86_64 required

Option-nodeps means ignore dependencies

[root@centos7 tmp] # rpm-Q vim-common vim-common-7.4.160-1.el7.x86_64 [root@centos7 tmp] # rpm-e-- nodeps vim-common warning: / etc/vimrc has been saved as / etc/vimrc.rpmsave [root@centos7 tmp] # rpm-Q vim-common does not have vim-common installed

Option-U means to upgrade the software package

[root@centos7 tmp] # rpm-Q wget wget-1.14-10.el7_0.1.x86_64 [root@centos7 tmp] # rpm-Uvh wget-1.14-13.el7.x86_64.rpm is in preparation. .. 1:wget-1.14-13.el7 # # [50%] cleaning / deleting... 2:wget-1.14-10.el7_0.1 # # [100%] [root@centos7 tmp] # rpm-Q wget wget-1.14-13.el7.x86_64

2. Yum download updater

Yum [options] [command] [package...]

Yum is an interactive software package manager based on rpm. Yum does not need to manually find the installation as rpm does when installing the software. It searches for rpm packages in the source as it works, automatically resolves dependencies, downloads and installs automatically. The yum default source configuration file is located in the directory / etc/yum.repos.d.

The command install indicates installation

[root@centos7 ~] # yum install vim-common loaded plug-in: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.yun-idc.com * extras: mirrors.yun-idc.com * updates: mirrors.yun-idc.com is resolving dependencies-- > checking transactions-- > the package vim-common.x86_64.2.7.4.160-1.el7 will be installed-- > resolving dependencies to complete dependency resolution. # omit partial output installation 1 Total downloads of software packages: 5.9m installation size: 21 M Is this ok [y/d/N]: y # need to enter here to confirm whether to install Downloading packages: vim-common-7.4.160-1.el7.x86_64.rpm | 5.9 MB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction warning: the RPM database has been modified by non-yum programs. * * an existing RPM database problem was found The yum check' output is as follows: 2:vim-enhanced-7.4.160-1.el7.x86_64 has missing requirements vim-common = ('2requests,' 7.4.160' '1.el7') in process of installation: 2:vim-common-7.4.160-1.el7.x86_64 1 2:vim-common-7.4.160 1 verification: 2:vim-common-7.4.160-1.el7.x86_64 1 Accord 1 has been installed: vim-common.x86_64 2 2:vim-common-7.4.160 7.4.160-1.el7 Over!

The command check-update means to check for updates

The command update indicates upgrade

The command search indicates to search for software packages

The command list lists the available software packages

The command remove means to uninstall

The command clean means to clear the contents of the yum cache directory

Option-y indicates that yes is entered by default in all places where interactive confirmation is required.

When there are no packages that need to be installed in the yum source, an error is reported that no packages are available. This can be solved by adding a new yum source

For example, install nginx in centos7:

# install repo [root@centos7 tmp] # rpm- ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm to get http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm warning: / var/tmp/rpm-tmp.cUANoe: header V4 RSA/SHA1 Signature Key ID 7bd9bf62: NOKEY preparation. # # [100%] upgrading / installing... 1:nginx-release-centos-7-0.el7.ngx # # [100%]

A new file nginx.repo has been added to / etc/yum.repos.d at this time

[root@centos7 tmp] # cat / etc/yum.repos.d/nginx.repo # nginx.repo [nginx] name=nginx repos # name baseurl= http://nginx.org/packages/centos/7/$basearch/ # Source address gpgcheck=0 # whether to check key,0 means not to check enabled=1 # where equal to 0 means that baseurl is not enabled, 1 means that baseurl is enabled

You can now install nginx with the command yum install-y nginx

You can also set up a local yum source when the server does not have a network available. At this point, you need to configure the repo file manually

First mount the installation CD or ios file to the system (see this article for more information on mounting)

[root@centos7 tmp] # mount CentOS-7-x86_64-DVD-1611.iso / media mount: / dev/loop2 write protection, will be mounted read-only [root@centos7 tmp] # # if it is CD-ROM: [root@centos7 tmp] # mount / dev/cdrom / media mount: / dev/sr0 write protection, will be mounted read-only [root@centos7 tmp] # # uninstall umount or eject [root@centos7 tmp] # umount / media [root@centos7 tmp] # eject

Edit yum source profile

Vim / etc/yum.repos.d/local.repo [local] name=test baseurl= file:///media # here baseurl writes the prefix (file://)+ mount point enabled=1 gpgcheck=0

Then back up the original network source configuration file to another directory, leaving only the local.repo file in / etc/yum.repo.d. Install the software:

Yum install bc-y

3. Source code package

The rpm and deb mentioned above are both binary packages, and since these packages have been compiled, users cannot set compilation options or make any changes to the software. Relatively speaking, compiling and installing software with source packages provides more flexibility, specifying a variety of options at compile time, and modifying the source code for capable users. Here's how to install the source package in linux

1) get the source package

Wget http://mirrors.sohu.com/nginx/nginx-1.9.6.tar.gz

2), decompression

Tar zxf nginx-1.9.6.tar.gz

3), configuration

[root@idc-v-71252 src] # cd nginx-1.9.6 [root@idc-v-71252 nginx-1.9.6] #. / configure-- prefix=/usr/local/nginx

Here the configuration option-prefix=/usr/local/nginx indicates that the installation path for nginx is specified as / usr/local/nginx.

You can execute. / configure-- help to see what configuration parameters are available, and the execution of this step checks whether the system meets the compilation requirements. If you report an error, in many cases it is due to the lack of compilation tools, which can be installed using yum (or source code, of course).

In this example, an error was reported:. / configure: error: the HTTP rewrite module requires the PCRE library.

If the pcre library is missing, take a look at the system:

[root@idc-v-71252 nginx-1.9.6] # rpm-qa pcre pcre-8.32-15.el7.x86_64 [root@idc-v-71252 nginx-1.9.6] #

The system has pcre installation, but no devel package, using yum installation

[root@idc-v-71252 nginx-1.9.6] # yum install pcre-devel-y

Execute configure again and find that the error has changed:. / configure: error: the HTTP gzip module requires the zlib library.

Repeat the above until the required software is installed, and then execute. / configure-- prefix=/usr/local/nginx again

4. Compilation

[root@idc-v-71252 nginx-1.9.6] # make-j8

Compile with make, and the option-j specifies the number of concurrent executions, which is the same as the number of system logical CPU (you can use the command grep-c "^ processor" / proc/cpuinfo to see the number of logical CPU).

Errors may also occur in this step, generally due to the lack of packages, so it is generally not difficult to read the error messages carefully.

5. Installation

[root@idc-v-71252 nginx-1.9.6] # make install

If there are no errors, the package is installed and the installed files can be found in / usr/local/nginx.

The general installation process of the source code package is described here. The installation of some source code packages may be different. There are corresponding installation instructions (README or INSTALL) in the general source code package. Read these files carefully or query the official website of the software to find their installation methods.

The above is all the contents of the article "sample Analysis of package Management in Linux". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

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

Servers

Wechat

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

12
Report