Linux Study Notes (11) software package management, linux Study Notes

Source: Internet
Author: User
Tags gpg

Linux Study Notes (11) software package management, linux Study Notes

Linux software packages include the source code package (script installation package) and Binary Package (RPM package and system default package ). The advantages of the source code package are:

1) The source code package is open-source. If you have sufficient capabilities, you can modify the source code;

2) You can freely select the required functions;

3) The source code package must be compiled and installed, so it is more suitable for your own system, stable and efficient;

4) Easy To uninstall. You only need to delete the installation file directory without any junk files.

Its disadvantage is:

1) There are many installation steps, especially when a large set of software is installed, spelling errors may easily occur;

2) the compilation process is long and the installation process is longer than that of the Binary Package;

3) it is difficult for new users to solve the problem once an error is reported during the installation because it is compiled and installed.

The advantages of a binary package are:

1) The package management system is simple. Only a few commands can be used to install, upgrade, and uninstall the package;

2) The installation speed is much faster than the source package.

Disadvantages:

1) the source code is no longer visible after compilation;

2) The function selection is not as flexible as the source code package;

3) strong dependence.

1 rpm command Management (1) Naming rules for rpm packages

Rpm packages such as: httpd-2.2.15-15.el6.centos.1.i686.rpm

Among them, httpd is the software package name, 2.2.15 is the software version, 15 is the number of software releases, el6.centos is a suitable Linux platform, i686 is a suitable hardware platform, and rpm is the rpm package extension.

(2) rpm dependency

Tree dependency: Package a depends on Package B, and Package B depends on Package c, that is, a-> B-> c. The sequence of uninstallation is c-> B->.

Ring dependency: for example, a-> B-> c-> a, you can install a, B, and c at the same time.

Module dependency: You can use the www.rpmfind.net website to query module dependencies.

(3) install, upgrade, and uninstall the rpm package

1) differences between full package name and package name

Full package name: when the operating package is a package that is not installed, the full package name will be used, and the path should also be noted.

Package name: When operating on installed software packages, the package name will be used, mainly to search for databases in/var/lib/rpm.

2) rpm installation, in the following format:

Full rpm-ivh package name

-I indicates install,-v indicates verbose,-h indicates hash, and -- nodeps indicates no dependency is detected.

3) The rpm package is upgraded in the following format:

Full name of rpm-Uvh package

The-U option indicates an update)

4) uninstall the rpm package in the following format:

Rpm-e package name

-E Indicates detaching (erase), and -- nodeps indicates no dependency check.

5) check whether the package is installed. The format is rpm-q package name. The-q option indicates query)

Query all installed rpm packages in the format of rpm-qa package names, where-a indicates all ).

6) query the software package details in the format of "rpm-qi", where "-I" indicates "information ), -p indicates querying uninstalled package information ).

7) query the installation location of files in the package. Format: rpm-ql package name. The-l option indicates list ), -p option can be used to check the directory in which files are to be installed (package) in uninstalled packages ).

8) which rpm package the System File belongs to? format: rpm-qf system file name. The-f option indicates the system file. The file must be a file generated after installation, files created by yourself cannot be queried.

9) query the dependency of a software package in the format of rpm-qR package name.-R indicates the dependency of the software package (requires ).

(4) checksum file Extraction

1) package verification mainly compares the original installation package to verify whether the file after package installation is modified. The format is:

Rpm-V package name already installed

The-V option indicates verify ).

For example, modify the comments section in/etc/yum. conf and perform verification.

[root@localhost Packages]# rpm -V yumS.5....T.  c /etc/yum.conf

The content of the first eight items in the verification content is as follows:

S

File size changed?

M

Whether the file type or File Permission (rwx) is modified

5

Whether the file MD5 checksum is changed (whether the file content is changed)

D

Device code changed?

L

File Path changed?

U

Does the file owner change?

G

Indicates whether the file group has changed.

T

Whether the file modification time has changed

The following 1 information indicates the file type, which mainly includes the following types:

C

Config file)

D

Documentation)

G

"Ghost" document (ghost file), that is, this file should not be included by this rpm package

L

License file)

R

Description file (readme)

2) Extraction of files in the rpm package, which is often used in misoperations. The format is:

Full name of rpm2cpio package | cpio-idv. Absolute file path

The rpm2cpio command is used to convert the rpm package into the cpio format. Cpio is a standard tool used to create software files and Extract files from them. The format is:

Cpio option <[file | device]

The-I option indicates "copy-in" mode, "-d" indicates that the directory is automatically created during restoration, and "-v" indicates that the restoration process is displayed.

Example:

Rpm-qf/bin/ls # query which package the ls command belongs to mv/bin/ls/tmp/# the illusion that the ls command is mistakenly deleted rpm2cpio/mnt/cdrom/Packages/coreutils-8.4 -- 19. el6.i686. rpm | cpio-idv. /bin/ls # extract the ls command from the rpm package to the/bin/ls cp in the current directory. /bin/ls/bin/# copy the ls command back to the/bin directory to fix file loss.

 

2 yum online management

Yum mainly solves the dependency problem of rpm packages. If the network is not connected, you can use the CD as the yum source.

(1) IP Address Configuration

You can use the setup command to set the IP address. After setting, you need to set the NIC to self-start, just change ONBOOT = "no" in/etc/sysconfig/network-scripts/ifcfg-eth0 to "yes. After setting, you need to restart the network service and execute the Command service network restart.

(2) network yum Source

The Network yum source is saved in the/etc/yum. repos. d/centos-Base.repo file.

[base]name=CentOS-$releasever - Basemirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

The file content has the following similar rules:

[Base] # container name, which must be placed in square brackets "[]"

Name # container description, which can be written by yourself

Mirror list # image site, which can be commented out

Baseurl # yum source server address

Enabled # Whether the container takes effect. 0 indicates that the container does not take effect. If this parameter is left blank, or 1 indicates that the container takes effect.

If gpgcheck # is set to 1, the rpm digital certificate takes effect. If it is set to 0, the certificate does not take effect.

Gpgkey # location where the public key file of the digital certificate is stored. Do not modify it here.

(3) yum command

Note that the yum command does not have the full package name concept!

1) query the list of all available software packages in the format of yum list. search for all keywords related packages on the server. The format is: yum search keyword.

2) The yum installation format is: yum-y install package name, where install indicates installation, and the-y option indicates Automatic Answer yes.

3) The yum upgrade format is: yum-y update package name, where update indicates the upgrade, and the-y option indicates the Automatic Answer yes.

Note: If the package name is not added, all software packages, including the Linux kernel, will be upgraded.

4) The format of yum uninstallation is: yum-y remove/erase package name, where remove/erase indicates uninstallation. Note that the dependent package will also be uninstalled when you use yum uninstallation, therefore, yum upgrade and yum uninstall should be used as little as possible.

5) yum software group management commands

List all available software groups in the format of yum grouplist

Install the specified software group (the group name can be identified by grouplist) in the following format:

Yum groupinstall software group name

Detach a specified software group in the format of yum groupremove

(4) yum source construction

The yum source can be obtained from the network or the system installation disc. Load the ISO image in VMware and select "connected", as shown in:

 

The following steps are as follows:

1) attach a CD. Create the CD mount point cdrom in the/mnt directory, and then use the mount command to mount the disk.

[root@localhost ~]# mkdir /mnt/cdrom[root@localhost ~]# mount /dev/cdrom /mnt/cdrommount: block device /dev/sr0 is write-protected, mounting read-only

2) make the network yum source invalid; otherwise, the network yum source will be automatically detected. Rename the file in the/etc/yum. repos. d/directory. Only CentOS_Media.repo is retained.

[root@localhost ~]# cd /etc/yum.repos.d/[root@localhost yum.repos.d]# lsCentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo  CentOS-Vault.repo[root@localhost yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.bak[root@localhost yum.repos.d]# mv CentOS-Debuginfo.repo CentOS-Debuginfo.repo.bak[root@localhost yum.repos.d]# mv CentOS-Vault.repo Debuginfo.repo.bak

3) modify the yum source file of the CD. The source file format must be strictly observed.

[Root @ localhost yum. repos. d] # vi CentOS-Media.repo [c6-media] name = CentOS-$ releasever-Mediabaseurl = file: // mnt/cdrom/# note the Mount address here for your own disc # file: /// media/CentOS/# comment out nonexistent addresses # file: // media/cdrom/# file: /// media/cdrecorder/gpgcheck = 1 enabled = 1 # Change 0 to 1 to make the yum source configuration file of the CD take effect. gpgkey = file: // etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

4) use the yum command for verification

[root@localhost yum.repos.d]# yum search zshLoaded plugins: fastestmirror, securityLoading mirror speeds from cached hostfile=====================N/S Matched: zsh =============================python-twisted-core-zsh.i686 : Tab completion for Zsh and Twisted Corezsh-html.i686 : Zsh shell manual in html formatzsh.i686 : A powerful interactive shell   Name and summary matches only, use "search all" for everything.
3. Source package management (1) differences between source package and rpm package

Before installation, there is a conceptual difference. After installation, the installation positions of the two are different. In general, the default installation location of the rpm package is as follows:

/Etc/

Configuration File Installation Directory

/Usr/bin/

Executable command installation directory

/Usr/lib/

Saved location of the function library used by the program

/Usr/share/doc/

Location of Basic Software User Manual

/Usr/share/man/

Help file storage location

The source code package is installed in a specified location, generally/usr/local/software name /. The services installed in the rpm package can be managed using the System service Management command (service.

For example, the startup method of apache installed in the rpm package is:

Service httpd start # Use service Management

/Etc/rc. d/init. d/httpd start # Use the absolute path to start

Note: The service command is private to RedHat, which searches for related services in the default system location.

Services installed in the source code package cannot be managed by service management commands. because services are not installed in the default path, you can only manage services in the absolute path.

For example, use the following method to start apache installed in the source code package:

/Usr/local/apache2/bin/apachetl start

(2) source code package installation process

Install the C language compiler gcc before installation. You can use yum install gcc for installation. Download the apache source code package: http://developer.bit.edu.cn/apache/httpd /. Note: the source code is saved at/usr/local/src, and the software is installed at/usr/local. When the installation process is stopped and an error, warning, or n prompt is displayed, the installation process is incorrect.

The installation process is as follows:

1) download the source code package

2) decompress the downloaded source code package and use the du-sh file name format to query the file or folder size.

3) enter the extract directory

4) Check the installation method in the INSTALL file that comes with the software. Brief description:

①. /Configure is mainly used for software configuration and check. The main functions to be executed include defining required functional options such as the installation directory and checking whether the system environment meets the installation requirements, write the defined function options and detection system environment information to the Makefile file for subsequent editing.

② Make compilation. If an error is reported, you can use make clean to clear all files.

③ Make install compile and install. This step truly writes data to the directory.

When uninstalling the source code package, you can directly Delete the installation directory without leaving any junk files.

4. Script installation package

The script installation package is not an independent software package type. The common installation is the source code package. In order to write the installation process as an automatic installation script, you only need to execute the script and define simple parameters, you can complete the installation, which is very similar to the installation method of software in windows, mainly used for hardware drivers.

For example, install webmin, which is a web-based linux system management interface. You can set user accounts, apache, DNS, file sharing, and other services in a graphical manner. The installation method is as follows:

1) download package: http://sourceforge.net/projects/webadmin/files/webmin.

2) decompress the package and enter the decompressed directory.

3) execute the installation script webmin. sh.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.