Linux applications, RPM software package management tools, source code compilation and installation, and Windos directory mounting and sharing

Linux application basics

The relationship between applications 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 a graphical interface, such as a firewall
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

Directory structure of a typical application

file type Save directory Description
Ordinary executable program file /usr/bin Executable by all users
Server program, management program file /usr/bin 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 page for executable files and configuration

Common package types

file type Description
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 Compressed packages generally in the format of ".tar.gz", ".tar.bz2", etc.
contain the original code of the program and need to be compiled and installed
Package with installer The software packages have different extensions. Most of them are in TarBall format.
The executable program or script file for installation is provided in the package, such as install.sh, setup, etc. During
installation, you only need to run the installation file to follow the wizard. Prompt to complete the installation operation

RPM package management tool

Red-Hat Package Manager

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

RPM package

General naming format
Insert picture description here

Format of RPM command

RPM commands can achieve almost all management functions for RPM software packages

Execute "man rpm" command to get detailed help information about rpm command

RPM command function
Query and verify the relevant information of the RPM software package
Install, upgrade, uninstall the RPM software package,
maintain and rebuild the RPM database information and other comprehensive management operations

Query RPM package information

Query information about installed RPM software

rpm -q[suboption] [software name]

Options Description
-q Query whether the specified software has been installed
-qi Display the detailed information of the specified software installed
-ql Display the file list of the specified software that has been installed
-qc List the installed configuration files of the specified software
-qd List the location of the package documentation of the specified software that has been installed
-qR List the dependent software packages and files of the installed specified software
-qf Query which installation package the specified software has been installed belongs to
-qa
example: rpm -qa 丨grep -i postfix
Display the list of all software installed in rpm mode in the current system,
filter in the list of all software through the pipe segment symbol, query whether postfix is ​​installed

Query the information in the RPM package file that is not installed

rpm -qp[suboption] RPM package file

Options Description
-qpi Query the detailed information of the specified software package
-qpl Query the file list of the specified software package
-qpc Query the configuration file of the specified software package
-qpd Query the location of the package documentation for the specified package

Install, upgrade, and uninstall RPM software packages

Install or upgrade RPM software

rpm [Options] RPM package...
rpm -ivh RPM package... (This command is the most commonly used command when installing RPM packages)

Options Description
-i Install a new RPM package
-U (uppercase) Upgrade a software package, if it has not been installed, install it
-F Upgrade a software package, if it has not been installed, then abandon the installation

Uninstall the specified RPM software

rpm -e software name
-e: uninstall the software package with the specified name

Auxiliary options

Options Description
-h In the process of installing or upgrading the software package, the installation progress will be displayed with "#"
-v Display detailed information during software installation
- -force Mandatory installation of a certain package, such as installing an older package
- -nodeps When installing, upgrading or uninstalling a software package, do not check dependencies with other software packages

Maintain RPM database

Rebuild the RPM database

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

rpm --rebuidddb or rpm --initdb

Import verification common key

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. You need to import the public key file located in the root directory of the CD into the RPM database.

mount /dev/sr0 /mnt/ (mount first)
rpm --import /mnt/RPM-GPG-KEY-CentOS-7 (re-import and specify the shared key file)

Solving package dependencies method

When multiple software with dependencies are installed

被依赖的软件包需要先安装
可同时指定多个 .rpm包进行安装

卸载有依赖关系的多个软件时

依赖其他程序的软件包需要先卸载
可同时指定多个软件名进行卸载

忽略依赖关系

结合 "- -nodps"选项,但可能导致软件异常

源代码编译安装

源代码编译概述

使用源代码安装软件的优点

获得最新的软件版本,即使修复BUG
根据用户需要,灵活定制软件功能

应用场合

安装较新版本的应用程序时
当前安装的程序无法满足需求时
需要为应用程序添加新的功能时

Tarball封包

源代码编译安装大多数都是使用Tarball安装
.tar.gz和.tar.bz2格式居多

完整性校验

md5sum校验工具
md5加密模式

确认源代码编译环境

需要支持C/C++程序语言的编译器
例如:gcc、gcc-c++、make等

编译安装过程

Insert picture description here

yum源仓库

因为安装源代码软件包需要编译安装,需要安装支持C和C++程序语言的编译器,而使用rpm安装则需要先安装多个依赖包,这样会很繁琐。所以这里可以使用yum方式进行一键安装

yum安装操作步骤

mount /dev/cdrom /mnt/          #光盘挂载到/mnt目录下
cd /etc/yum.repos.d/
mkdir  repos.bak                #创建一个新目录用来存放本目录内 .repo 格式的文件
mv *.repo  repos.bak

cd /etc/yum.repos.d/            #回到目录
vim local.repo                  #进入local.repo进行配置
[local]                         #仓库类别
name=local                      #仓库名称
baseurl=file:///mnt             #指定 URL 访问路径为光盘挂载目录 /mnt
enabled=1                       #开启此yum源,此为默认项,可省略
gpgcheck=0                      #不验证软件包的签名

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

先要配置本地yum源仓库
mount /dev/cdrom /mnt/ (先把光盘挂载到/mnt目录下)
cd /etc/yum.repos.d/(进入目录)
mkdir repos.bak(创建repos.bak目录用作备份)
mv *.repo repos.bak(将所有以.repo结尾的文件全部放入repos.bak文件)

cd /etc/yum.repos.d/(进入目录)
vim local.repo(用vim打开/创建一个新文件)
[local] (仓库类别)
name=local (仓库名称)
baseurl=file:///mnt (指定URL访问路径为光盘挂载目录)
enabled=1(开启此yum源,为默认选项,可忽略)
gpgcheck=0 (不验证软件包的签名)

yum clean all && yum makecache (删除yum缓存并更新,&&代表当前面的命令成功后才会执行后面的命令)

yum常用命令

命令 说明
yum -y install 软件名 安装、升级软件包,“-y”选项表示自动确认
yum -y remove 软件名 卸载软件包,可自动解决其依赖关系
yum -y update 软件名 升级软件包
yum list 查询软件包列表
yum list installed 查询系统中已安装的软件包
yum list available 查询仓库中尚未安装的软件包
yum list updates 查询可以升级版本的软件包
yum info 软件名 查询软件包的描述信息
yum search [all] 关键字 根据某个关键词来查找相关的软件包
yum whatprovies 命令 查询命令属于哪个软件包

挂载Windows中的共享目录

Windos端共享权限设定

1.解禁Guest
右击我的电脑选择管理→本地用户和组→在用户选项汇总双击Guset用户→取消账号已禁用选项

2.设置共享目录权限
右击共享目录点属性→在共享页面中点击共享选项→下拉选择共享对象为Everyone→点击共享按钮

3. Set the local policy
Open the command box → enter sepol.msc → select the local policy
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 guest

Linux mount side

1. Scan the
QR code to share the directory smbclient -L //XXX.XXX.XXX.XXX/ (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
mount.cifs //xxx.xxx.xxx.xxx/share /data
directly press Enter without entering a password

Guess you like

Origin blog.csdn.net/TaKe___Easy/article/details/113362534