Linux installation and management tools (rpm and yum)

One, the basics of Linux applications

(1) The relationship between application programs and system commands

Character System command application
File location -Generally in the /bin and /sbin directories, or shell internal commands Usually in /usr/bin, /usr/sbin and /usr/local/bin, /usr/local/sbin
The main purpose Complete the basic management of the system, such as IP configuration tools Complete other relatively independent auxiliary tasks, such as a web browser
Applicable environment Generally only run in the character operation interface According to actual needs, some programs can be run in the graphical interface
Run format Generally include command words, command options and command parameters Usually there is no fixed execution format, which is defined by the program developer

(2) Directory structure of typical applications

file type Save directory Description
Ordinary executable program /usr/bin Executable by all users
Server program, management program command /usr/sbin Only the administrator can execute
Application configuration file /etc Applications installed via rpm or yum
Log file / var / log System log
Application Reference Document File /usr/share/doc Reference documents and other data about the application
Application man page file /usr/share/man Man manual for execution files and configuration files

(3) Common package types

file type Save directory
RPM package The extension is ".rpm", suitable for RHEL, CentOS and other systems
DEB software package The extension is ".deb", suitable for Ubuntu, Debian and other systems
Source code package Generally, it is a compressed package in the format of ".tar.gz", ".tar.bz2", etc., which contains the original code of the program and needs to be compiled and installed
Package with installer The extension of the software package is mostly in TarBall format, and the executable program or script file for installation will be provided in the software package. For example: install.sh, setup, etc., you only need to run the installation file during installation to complete the installation operation according to the prompts of the wizard program

Two, RPM package management tool

(I. Overview

1. RPM package manager Red-Hat Package Manager

1. Proposed by Red Hat and adopted by many Linux distributions
2. Establish a unified file database
3. Detailed record of software package installation, uninstallation, upgrade and other change information
4. Automatic analysis of software package dependencies

2. RPM package

1. Software material reference: http://www.rpm.org
2. General naming format: Insert picture description here
for example: libusal-1.1.11-23.el7.x86_64.rpm (you can use rpm -qi libusal to query software details)
software name : Libusal Version number: 1.1.11 Number of releases: 23.el7 (23 releases of el7: CentOS 7) Hardware platform: x86_64 Extension: .rpm

(2) RPM command format

1. The rpm command can realize almost all the management functions of the RPM software package.
2. Execute the "man rpm" command to get detailed help information about the rpm command.
3. The function of the rpm command

  • Query and verify the relevant information of the RPM software package
  • Install, upgrade, and uninstall RPM software packages
  • Maintenance and reconstruction of RPM database information and other comprehensive management operations

(3) Query RPM package software information

1. Query the installed rpm software information

rpm -q 软件名      查询指定软件名(完整名称)是否已安装
rpm -qi 软件名     显示已安装的指定软件的详细信息 
rpm -ql 软件名     显示已安装的指定软件的文件列表 
rpm -qc 软件名     列出已安装的指定软件的配置文件 
rpm -qd 软件名     列出己安装的指定软件的软件包文档所在位置 
rpm -qR 软件名     列出己安装的指定软件的依赖的软件包及文件
rpm -qF 文件或目录  查询已安装的指定软件属于哪个安装包 

rpm -qa    显示当前系统中以 rpm方式安装的所有软件列表 
rpm -qa | grep -i postfix    查询软件postfix是否已安装(可以不是完整的软件名)

2. Query the information in the RPM software package file that is not installed

rpm -qpi RPM包文件名     查询指定软件包的详细信息 
rpm -qpl RPM包文件名     查询指定软件包的文件列表 
rpm -qpc RPM包文件名     查询指定软件包的配置文件 
rpm -qpd RPM包文件名     查询指定软件包的软件包文档的位置

(4) Install, upgrade, and uninstall RPM software packages

1. Command format

rpm [选项] RPM包文件
rpm -ivh RPM软件包

2. Common options

  • -i: Install a new RPM package.
  • -U: upgrade a software package, if it has not been installed, install it
  • -F: Upgrade a certain software package, if it has not been installed, abort the installation.
  • -h: In the process of installing or upgrading the software package, the installation progress will be displayed with "#"
  • -v: Display detailed information during the software installation process.
  • --force: Mandatory installation of a certain package, such as installing an older package
  • -e: Uninstall the software package with the specified name.
  • - -nodeps: When installing, upgrading, or uninstalling a software package, the dependencies with other software packages are not checked.

(5) Maintain the RPM database

1. Rebuild the RPM database

1. When the RPM database is damaged, it can be repaired by rebuilding the RPM database

rpm --rebuilddb		或者		rpm --initdb

2. Import the verification public key

1. Before importing the public key file for digital signature verification, an error will be reported when installing part of the RPM software package in the CD. Need to import the public key file located in the root directory of the CD into the RPM database

mount /dev/sr0 /mnt/     挂载光盘
rpm --import /mnt/RPM-GPG-KEY-CentOS-7   切换到挂载目录查看目录信息ls

(6) Resolve dependencies

1. When multiple software with dependencies are installed

  • Dependent packages need to be installed first
  • Multiple .rpm package files can be specified for installation at the same time

2. When uninstalling multiple software with dependencies

  • Packages that depend on other programs need to be uninstalled first
  • Can specify multiple software names to uninstall at the same time

3. Ignore dependencies,
combined with the "-nodeps" option, but may cause software exceptions

If you use the rpm method to install, you need to install multiple dependent packages first, which will be very cumbersome. Here you can use yum to perform one-click installation

Three, source code compilation

(I. Overview

1. Advantages

1. Obtain the latest software version and fix bugs in time
2. According to user needs, flexibly customize the software function application examples

2. Application scenarios

1. When a newer version of the application is
installed 2. When the currently installed program cannot meet the needs
3. When a new function needs to be added to the application

3. Tarball packet

1. Tar.gz and .tar.bz2 formats are mostly
2. Software material reference: http://sourceforge.net integrity check

4. Integrity check

1.md5sum verification tool
md5sum httpd-2.4.25.tar.gz
24fb8b9e36cf131d78caae864fea0f6a httpd-2.4.25.tar.gz confirm

5. Source code compilation environment

Need to install a compiler that supports C/C++ programming language, such as: gcc, gCC-C++, make,...

6. Compile and install process

Insert picture description here

Four, yam installation

(1) Configure the local yum source warehouse

mount /dev/cdrom /mnt/	把光盘挂载到/mnt目录下

cd /etc/yum.repos.d/     包含了一些安装包不建议删除,可以创建一个目录做备份
mkdir repos.bak        创建备份目录
mv *.repo repos.bak    移动所有以.repo为后缀的文件到备份目录中

vim local.repo
[local]			仓库类别
name=local		仓库名称与所创建的文件名一致
baseurl=file:///mnt	指定URL 访问路径为光盘挂载目录,file://(格式)/mnt(目录)
enabled=1		开启此yum源,此为默认项,可省略
gpgcheck=0		不验证软件包的签名

yum clean all && yum makecache      删除yum缓存并更新

yum clean                           可以拆分成两个步骤来进行
yun makecache

(Two) yum common operation commands

yum -y install 软件名	安装、升级软件包,“-y”选项表示自动确认
yum -y remove 软件名	卸载软件包,可自动解决其依赖关系
yum -y update 软件名     升级软件包

yum list		查询软件包列表
yum list installed      查询系统中已安装的软件包
yum list available	查询仓库中尚未安装的软件包
yum list updates	查询可以升级版本的软件包

yum info 软件名	        查询软件包的描述信息
yum info httpd

yum search [all] 关键词	  根据某个关键词来查找相关的软件包
yum search all httpd      根据httpd关键词来查找相关的软件包

yum whatprovides 命令	    查询命令属于哪个软件包
yum whatprovides netstat    查询netstat命令属于哪个软件包

(3) Use yum to install

1.yum install -y gcc gcc-c++ make

5. Mount the shared directory in Windows (Supplement)

(1) Windos end sharing permission setting

1. Unblock Guest,
right-click on My Computer and select Manage-Local Users and Groups-Double-click the Guset user in the user options summary-Cancel the account has been disabled option
2. Set the shared directory permissions,
right-click the shared directory point properties-on the sharing page Click on the sharing option in the drop-down menu to select the shared object as Everyone, click on add to select read and write-click on the share button
Insert picture description here

3. Set the local strategy
Open the command box-enter sepol.msc-select the local strategy
User permission assignment-deny access to this computer from the network-delete the guest user
security option-network access: local account sharing and security Model-drop down to select only guests

(2) Linux mount end

1. Scan the shared directory
smbclient -L //192.168.71.1/ (IP address on the Windows side)
directly press Enter without entering the password
2. Mount the shared directory
yum install -y cifs-utils
mkdir /data
Insert picture description here

3.mount.cifs //192.168.71.1/share /data ###share: The directory to be shared, here I use the folder of windows commonly used software for sharing. You
don’t need to enter a password and press Enter.

4.df -h #View mounted
ls / data #Display the contents of the mounted directory
Insert picture description here

(3) Problems arising from the specific operation process

Problem one (protocol negotiation failed: connection reset): protocol negotiation failed: NT_STATUS_CONNECTION_RESET
Insert picture description here

**Solution: **vim /etc/samba/smb.conf modify the file, add the following two parameter items under the global label:
client min protocol = CORE
client max protocol = SMB3

Insert picture description here

Problem two:Insert picture description here
**Solution: **Open the windows control panel—>Programs—>Programs and Features—>Start or close windows functions
Insert picture description here

Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_53567573/article/details/113625550