In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)05/31 Report--
Today, I would like to share with you the relevant knowledge about how to install, upgrade and uninstall software packages in LINUX. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article.
one。 Overview of RPM package installation 1.1 rpm
RPM is Red Hat Packege Manager and Red Het software manager. Mainstream Linux distributions such as Fedora, Red Hat, CentOS, SUSE, Mandrake and so on use this software package management mode by default.
Class and composition of RPM package
File meaning corresponding to rpm: httpd-2.2.15-29.el6.centos.x86_64.rpm
Httpd / / indicates the name of the software
2.2.15 / / indicates the version number of the software
29 / / indicates the number of software updates released
X86room64 / / indicates a platform suitable for hardware
.rpm / / is the identity of the rpm software package
1.2 rpm package Management
1. View installed rpm packages
Rpm
Syntax: rpm [suboption] [software name]
Suboption
-qa / / View the list of all rpm packages installed on the system
-qi / / View the details of the specified software installed on the system
-ql / / View the list of directories and files installed by the specified software package
-qc / / displays only the configuration files of the installation package
-pd / / displays only the installation documentation file for the specified software installation package
Example
Rpm-qa httpd / / View the installation of the httpd package
two。 View information about rpm packages
Rpm
Syntax: rpm-qp [suboptions] [RPM package]
Suboption
-qpi / / View the details of the software through the .rpm package file
-qpl / / View the directory and file list contained in the .rpm installation package
-qpc / / View the list of configuration files contained in the .rpm installation package
-qpd / / View the list of document files contained in .rpm
Example:
Rpm-qpi httpd-2.2.15-29.el6.centos.x86_64.rpm / / View the details of the httpd main package
3. Install upgrade updates, uninstall, integrity check
Rpm
Syntax: rpm [suboptions] [rpm package files] [secondary options]
Suboption
-I / / install a new rpm package
-U / / upgrade a rpm package, if it is not installed, install it
-F / / Update a rpm package. If it is not installed, the installation will be abandoned.
-e / / Uninstall the specified rpm software installation package
Example
Rpm-I httpd-2.2.15-29.el6.centos.x86_64.rpm / / install the httpd main program
Rpm-U httpd-2.2.15-30.el6.centos.x86_64.rpm / / Update install httpd main program
Rpm-F httpd-2.2.15-30.el6.centos.x86_64.rpm / / Update httpd main program
Rpm-e httpd / / Uninstall the httpd main program
Note: a dependency relationship will be encountered when uninstalling, which needs to be used in conjunction with the auxiliary options below
4.rpm ancillary option
-- force / / Force installation of the specified rpm package
-- nodeps / / ignore package dependencies when installing, upgrading, or uninstalling software
-h / / display the installation progress with the "#" sign
-v / / displays details during installation
Example
Rpm-Ivh httpd-2.2.15-30.el6.centos.x86_64.rpm / / displays installation information and installation progress
Rpm-e httpd-nodeps / / forcibly uninstall httpd software
Rpm-ivh httpd-2.2.15-30.el6.centos.x86_64.rpm-force / / mandatory installation of httpd software
5. Maintain rpm database
Rebuild rpm
Rpm-rebuilddb / / reset rpm database
Rpm-initdb / / reset rpm database
Import public key
Syntax rpm-- import [path where the public key file is located]
Software package complete check
Use md5 query
Syntax: md5sum [software installation package]
Example:
Md5sum httpd-2.2.15-29.el6.centos.x86_64.rpm / / get the password of the httpd main package
Whether the file has been tampered with when viewing the file
Syntax: rpm-K [software installation package]
Example:
Rpm-K httpd-2.2.15-29.el6.centod.x86_64.rpm / / detects whether the httpd main package has been tampered with
two。 Source code compilation and installation software
Confirm the source code compilation environment
Gcc-version
Gmail +-- version
Source code package installation process
Step 1:tar unpack
Purpose: extract and release the source code package to the specified directory
Step 2:./configure configuration
Syntax. / configure-- prefix = [installation path]
Purpose: set up installation directory, installation module and other options
Step 3:make compilation
Purpose: survival of executable binaries
Step 4:make install installation
Purpose: copy binary file system configuration application environment
2.1. / detailed explanation of configure parameters
-- cache-file=FILE
Configure' will test existing features (or bug!) on your system. To speed up subsequent configuration, the test results are stored in a cachefile. When configure has a complex source tree with 'configure' scripts in every subtree, the existence of a good cache file helps a lot.
-- help
Output help information. Even experienced users occasionally need to use the'--help' option because a complex project contains additional options. For example, the 'configure' script in the GCC package contains options that allow you to control whether to generate and use the GNU assembler in GCC.
-- no-create
One of the main functions in configure' makes the output file. This option prevents' configure' from generating this file. You can think of this as a dry run, although the cache is still rewritten.
-- quiet
-- silent
When configure' conducts his test, he outputs brief information to tell the user what he is doing. This is because 'configure' may be slow, without which users will be left wondering what's going on. Using either of these two options will throw you aside. (translation note: these two sentences are more interesting, the original text is as follows:
If there wasno such output, the user would be left wondering what is happening. Byusing this option, you too can be left wondering!)
-- version
Print the version number of the Autoconf used to generate the 'configure' script.
-- prefix=PREFIX
-- prefix' is the most commonly used option. The created 'Makefile' will view the parameters passed with this option, and when a package is installed, it can completely relocate its structural independent parts. For example, when installing a package, such as Emacs, the following command will cause Emacs Lisp file to be installed to "/ opt/gnu/share":
$. / configure-prefix=/opt/gnu
-- exec-prefix=EPREFIX
Similar to the'--prefix' option, but it is used to set the installation location of files on which the structure depends. The compiled 'emacs' binary file is such a question. If this option is not set, the default option will be set to the same value as the'--prefix' option.
-- bindir=DIR
Specify the location where the binaries are installed. The binaries here are defined as programs that can be executed directly by the user.
-- sbindir=DIR
Specify the installation location of the super binaries. These are programs that are usually executed only by superusers.
-- libexecdir=DIR
Specify the installation location of the executable support files. In contrast to binaries, these files are never executed directly by the user, but can be executed by the binaries mentioned above.
-- datadir=DIR
Specify the installation location of the common data file.
-- sysconfdir=DIR
Specifies the installation location of read-only data used on a single machine.
-- sharedstatedir=DIR
Specifies the installation location of writable data that can be shared on multiple machines.
-- localstatedir=DIR
Specify the installation location of writable data that can only be used on a stand-alone machine.
-- libdir=DIR
Specify the location where the library files are installed.
-- includedir=DIR
Specify the installation location of the C header file. This option can also be used for header files in other languages such as C++.
-- oldincludedir=DIR
Specifies the installation location of C header files installed for compilers other than GCC.
-- infodir=DIR
Specifies the installation location of the Info format document. Info is the document format used by the GNU project.
-- mandir=DIR
Specify the installation location of the manual page.
-- srcdir=DIR
This option has no effect on installation. He will tell 'configure' the location of the source code. Generally speaking, you do not need to specify this option, because the 'configure' script is usually in the same directory as the source file.
-- program-prefix=PREFIX
Specifies the prefix that will be added to the name of the installed program. For example, using'--program-prefix=g' to configure a program named 'tar' will cause the installed program to be named' gtar'. When used with other installation options, this option works only if it is used by the `Makefile.in' file.
-- program-suffix=SUFFIX
Specifies the suffix that will be added to the name of the installed program.
-- program-transform-name=PROGRAM
The PROGRAM here is a sed script. When a program is installed, its name will go through `installation-e PROGRAM' to generate the name of the installation.
-- build=BUILD
Specify the system platform on which the package is installed. If not specified, the default value will be the value of the'--host' option.
-- host=HOST
Specify the system platform on which the software runs. If not specified, `config.guess' will be run to detect.
-- target=GARGET
Specify the software-oriented (target to) system platform. This mainly works in the context of programming language tools such as compilers and assemblers. If not specified, the value of the'--host' option is used by default.
-- disable-FEATURE
Some packages can choose this option to provide compile-time configuration for large options, such as using a Kerberos authentication system or an experimental compiler optimal configuration. If these features are provided by default, you can use'--disable-FEATURE' to disable it, where 'FEATURE' is the name of the feature. For example:
$. / configure-disable-gui
-- enable-FEATURE [= ARG]
On the contrary, some packages may provide features that are disabled by default, which can be used using'--enable-FEATURE'. Here 'FEATURE'' is the name of the feature. A feature may accept an optional parameter. For example:
$. / configure-enable-buffers=128
`--enable-FEATURE=no' is synonymous with the aforementioned'--disable-FEATURE'.
-- with-PACKAGE [= ARG]
In the free software community, there is an excellent tradition of using existing software packages and libraries. When configuring a source tree with 'configure', you can provide information about other installed packages. For example, BLT device kits that rely on Tcl and Tk. To configure BLT, you may need to provide 'configure' with some information about where we installed Tcl and Tk:
$. / configure-with-tcl=/usr/local-with-tk=/usr/local
'--with-PACKAGE=no' is synonymous with'-- without-PACKAGE', which will be mentioned below.
-- without-PACKAGE
Sometimes you may not want your package to interact with existing packages in the system. For example, you may not want your new compiler to use GNU ld. You can do this by using this option:
$. / configure-without-gnu-ld
-- x-includes=DIR
This option is a special case of the'--with-PACKAGE' option. When Autoconf was first developed, it was popular to use 'configure' as a workaround for Imake to make software running on X.'-- the x includes option provides a way to indicate to a 'configure' script a directory containing X11 header files.'-similarly, the'- x color libraries` option provides a way to indicate to a 'configure' script a directory containing X11 libraries. Running 'configure' in the source tree is unnecessary and bad. A good Makefile' generated by configure' can build a software package where the source code belongs to another tree. The benefits of building derived files in a tree independent of the source code are obvious: derived files, such as target files, are cluttered across the source tree. This also makes it very difficult to build the same object file on a different system or with different configuration options. Three trees are recommended:
1. Insert a patch
Patch-p1
< [需要打补丁的安装文件] 三. YUM安装软件3.1 yum概述 Yum(全称为 Yellow dog Updater, Modified)是一个在Fedora和RedHat以及CentOS中的shell前端软件包管理器。基于RPM包管理,能够从指定的服务器自动下载RPM包并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软件包,无须繁琐地一次次下载、安装命名为YUM。 使用yum工具管理软件包 yum的配置文件 基本配置文件:/etc/yum.conf 仓库设置:/etc/yum.repos.d/*.repo 日志文件:/var/log/yum.log yum缓存目录(存放下载的软件包、仓库信息等数据) /var/cache/yum/$basearch/$releasever #yum clean all //清理缓存数据 软件包查询 yum list 软件名 //查询软件包列表 [root@localhost 桌面]#yum list updates //查询更新列表 yum info 软件名 //查询软件包描述信息 yum search all 关键词 //关键词查询相关软件包 查询软件包组 yum grouplist 包组名 yum groupinfo 包组名 软件安装 yum install 软件名 -y 表示自动确认 yum groupinstall 包组名 升级软件 yum update 软件名 yum groupupdate 软件组名 卸载软件 yum remove 软件名 yum groupremove 包组名 [root@localhost 桌面]#yum -y groupremove "Desktop" 3.2构建yum数据库 准备安装源(服务器端) 软件仓库的提供方式 FTP服务:ftp://... HTTP服务:http://... 本地目录:file:///.. RPM软件包的来源 Red Hat发布的RPM包** 第三方组织发布的RPM包** 用户自定义的RPM包** 3.2.1创建本地yum源 [root@localhost 桌面]#mkdir /media/cdrom //创建cdrom目录 [root@localhost 桌面]#mount /dev/cdrom /media/cdrom //挂载光驱到/media/cdrom下 [root@localhost 桌面]#cd /etc/yum.repos.d/ //切换到yum源所在路径 [root@localhost yum.repos.d]#mkdir 1 //创建一个1目录 [root@localhost yum.repos.d]#mv *.repo 1 //将原有的源移动到1目录中 [root@localhost yum.repos.d]#vim local.repo //编写本地源文件 [base] //yum本地库名称 name=Red Hat Enterprise Linux //名称描述 baseurl=file:///media/cdrom //指定本地源路径 enabled=1 //启用该本地源 gpgcheck=1 //gpg检测开启 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release //指定gpg-key路径 注意:如果gpgcheck=0,就不用写gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release 3.2.2配置ftp共享yum源(服务器端) [root@localhost 桌面]#vim /etc/sysconfig/network-scripts/ifcnfig-eth0 //配置IP [root@localhost 桌面]#service network restart //重启网络服务 [root@localhost 桌面]#mkdir /media/cdrom //创建cdrom目录 [root@localhost 桌面]#mount /dev/cdrom /media/cdrom //挂载光驱到/media/cdrom下 [root@localhost 桌面]#cd /media/cdrom/Packages/ //切换到光盘挂载点的包目录 [root@localhost Packages]# rpm -ivh vsftpd-2.2.2-11.el6_4.1.x86_64.rpm //安装vsftpd软件 [root@localhost Packages]#mkdir /var/ftp/cent //在ftp默认路径下,创建一个cent目录 [root@localhost Packages]#cp * /var/ftp/cent/ //将当前目录中的所有内容复制到ftp目录下cent目录中 [root@localhost 桌面]#service vsftpd start //开启vsftpd服务 [root@localhost 桌面]#cd /etc/yum.repos.d/ //切换到yum源所在路径 [root@localhost yum.repos.d]#mkdir 1 //创建一个1目录 [root@localhost yum.repos.d]#mv *.repo 1 //将原有的源移动到1目录中 [root@localhost yum.repos.d]#vim local.repo //编写本地源文件 [base] //yum本地库名称 name=Red Hat Enterprise Linux //名称描述 baseurl=ftp://[当前服务器IP]/cent //指定本地源路径 enabled=1 //启用该本地源 gpgcheck=1 //gpg检测开启 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release //指定gpg-key路径 3.2.3配置ftp共享yum源(客户端) 注意:确保客户端与服务器端网络能够正常通信 [root@localhost 桌面]#cd /etc/yum.repos.d/ //切换到yum源所在路径 [root@localhost yum.repos.d]#mkdir 1 //创建一个1目录 [root@localhost yum.repos.d]#mv *.repo 1 //将原有的源移动到1目录中 [root@localhost yum.repos.d]#vim local.repo //编写本地源文件 [base] //yum本地库名称 name=Red Hat Enterprise Linux //名称描述 baseurl=ftp://[YUM服务器IP]/cent //指定yum服务器yum源路径 enabled=1 //启用该本地源 gpgcheck=1 //gpg检测开启 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release //指定gpg-key路径 四. PXE网络安装操作系统 服务器的批量部署准备阶段 规模化:同时装配多台服务器 自动化:安装系统、配置各种服务 远程实现:不需要光盘、U盘等安装介质 关于PXE网络 PXE,Pre-boot eXcution Environment 预启动执行环境,在操作系统之前运行 可用于远程安装、构建无盘工作站 服务端 运行DHCP服务,用来分配地址、定位引导程序 运行TFTP服务器,提供引导程序下载 客户端 网卡支持PXE协议 主板支持网络启动 4.1搭建PXE远程安装服务器 准备安装YUM源仓库 [root@localhost 桌面]#vim /etc/sysconfig/network-scripts/ifcnfig-eth0 //配置IP [root@localhost 桌面]#service network restart //重启网络服务 [root@localhost 桌面]#mkdir /media/cdrom //创建cdrom目录 [root@localhost 桌面]#mount /dev/cdrom /media/cdrom //挂载光驱到/media/cdrom下 [root@localhost 桌面]#cd /media/cdrom/Packages/ //切换到光盘挂载点的包目录 [root@localhost Packages]# rpm -ivh vsftpd-2.2.2-11.el6_4.1.x86_64.rpm //安装vsftpd软件 [root@localhost Packages]#mkdir /var/ftp/cent //在ftp默认路径下,创建一个cent目录 [root@localhost Packages]#cp * /var/ftp/cent/ //将当前目录中的所有内容复制到ftp目录下cent目录中 [root@localhost 桌面]#service vsftpd start //开启vsftpd服务 [root@localhost 桌面]#cd /etc/yum.repos.d/ //切换到yum源所在路径 [root@localhost yum.repos.d]#mkdir 1 //创建一个1目录 [root@localhost yum.repos.d]#mv *.repo 1 //将原有的源移动到1目录中 [root@localhost yum.repos.d]#vim local.repo //编写本地源文件 [base] //yum本地库名称 name=Red Hat Enterprise Linux //名称描述 baseurl=ftp://[当前服务器IP]/cent //指定本地源路径 enabled=1 //启用该本地源 gpgcheck=1 //gpg检测开启 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release //指定gpg-key路径安装并启用TFTP服务 [root@localhost yum.repos.d] #yum -y install tftp-server //使用yum安装tftp服务 [root@localhost yum.repos.d] #vi /etc/xinetd.d/tftp //修改tfpt主配置文件 disable =no //更改此项yes为no [root@localhost yum.repos.d]#service xinetd start //启动tftp服务 准备Linux内核、初始化镜像文件 用于PXE网络安装的Linux内核、初始化镜像文件可以从RHEL6系统光盘获得,分别为vmlinuz和initrd.img [root@localhost yum.repos.d]#cd /media/cdrom/images/pxeboot //进入光盘镜像pxe引导目录下 [root@localhost pxeboot]#cp vmlinuz initrd.img /var/lib/tftpboot //将内核文件和初始化文件拷贝到tftp引导目录下 4.2准备PXE引导程序、启动菜单文件 用于PXE网络安装的引导程序pxelinux.0,由软件包syslinux提供 [root@localhost pxeboot]#yum -y install syslinux //安装网络安装的引导程序syslinux程序[root@localhost pxeboot]#cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot //将pxe引导程序拷贝到tftp引导 目录下 默认的启动菜单文件为default,应放置子tftp根目录的pxelinux.cfg子目录下 [root@localhost pxeboot]#mkdir /var/lib/tftpboot/pxelinux.cfg //创建默认启动菜单的目录 [root@localhost pxeboot]#vi /var/lib/tftpboot/pxelinux.cfg/default //编写默认启动菜单 default auto //默认为自动 prompt 1 //启用提示等待 label auto //自动执行标签 kernel vmlinuz //内核文件为vmlinuz append initrd=initrd.img devfs=nomount ramdisk_size=8192 //确定初始化格式和大小 label linux text kernel vmlinuz append text initrd=initrd.img devfs=nomount ramdisk_size=8192 label linux rescue kernel vmlinuz append rescue initrd=initrd.img devfs=nomount ramdisk_size=8192 安装并启用DHCP服务 [root@localhost pxeboot]#yum -y install dhcp //安装DHCP软件包 [root@localhost pxeboot]#vi /etc/dhcp/dhcpd.conf //配置dhcp主配置文件 subnet 192.168.4.0 netmask 255.255.255.0 { //指定DHCP分配网段 …… option routers 192.168.4.254; //指定路由IP option domain-name-servers 192.168.4.254,202.106.0.20; //指定DNS服务ip地址 range 192.168.4.100 192.168.4.200; //划定分配ip地址范围 next-server 192.168.4.254; //指定TFTP服务器地址 filename "pxelinux.0"; //指定PXE引导程序文件名 } #service dhcpd start //重启DHCP服务 4.3客户端测试PXE网络安装 确保电脑网卡正常 在blos中将开机主引导设置为pxe引导 kickstart无人值守技术 创建应答文件,预先定义好各种安装设置 免去交互设置过程,从而实现全自动化安装 通过添加%post脚本,完成安装后的各种配置操作 桌面菜单"应用程序"-系统工具-Kickstart-保存/root/ks.cfg [root@localhost pxeboot]#yum -y install system-config-kickstart //安装桌面配置应用程序 配置安装完成后执行列程序完成客户机ftp共享yum源仓库的连接 安装后脚本 %post --interpreter=/bin/bash rm -f /etc/yum.repos.d/* //删除客户机原有yum源仓库 echo '[base] //yum仓库名 name=Red Hat Enterprise Linux //名称描述 baseurl=ftp://192.168.4.254/cent //yum源包路径 enabled=1 //启用本地源 gpgcheck=1 //启用gpg校验 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release' >/ etc/yum.repos.d/rhel6.repo / / specify the path of the gpg check code
% end / / end
Realization of batch automatic installation with PXE+kickstart
[root@localhost pxeboot] # cp / root/ks.cfg / var/ftp/rhel6/ks.cfg / / copy the template file configured by the system to the yum source path of ftp share
Modify the startup menu file and call the answer file
[root@localhost pxeboot] # vi / var/lib/tftpboot/pxelinux.cfg/default / / modify the default startup path
Default auto / / defaults to automatic
Prompt 0 / / cancel prompt to wait
Label auto / / marked as automatic
Kernel vmlinuz / / specify kernel file
Append ks= ftp://192.168.4.254/rhel6/ks.cfg initrd=initrd.img devfs=nomount ramdisk_size=8192 / / additional template path, initialization format and size
These are all the contents of this article entitled "how to install, upgrade and uninstall software packages in LINUX". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.