关于软件管理

mac2024-12-15  22

1.用rpm命令处理软件

rpm -i安装rpm -v显示过程rpm -hhash加密rpm -e卸载rpm -q查看rpm -a所有rpm -p软件包rpm -ql查看软件在系统中的安装文件路径rpm -qlp查看未安装的软件包在系统中如果安装后产生文件的路径rpm -qf根据某个文件找出此文件属于哪个安装包rpm -qc查看软件的配置文件名称rpm -qd查看软件的帮助文件rpm --scritps查看脚本rpm --nodeps安装软件忽略软件依赖rpm -force强行安装软件rpm -Kv检测软件包是否被篡改

2.yum

1.yum命令的使用必须是在yum源搭建成功后才能正常运行

2.yum命令的详细用法

yum clean all清除原有yum源yum repolist列出仓库信息yum install software安装yum update更新yum list software查看软件yum list all查看所有软件yum list installed列出已安装软件yum list available列出可安装的软件yum reinstall software重新安装yum remove software卸载yum info software查看软件信息yum search software信息根据软件信息查找软件yum whatprovides file根据文件找出包含此文件的软件yum history查看系统中软件管理信息yum history info 数字对该数字为id的信息进行显示yum groups list列出软件组yum groups info查看软件组的信息yum groups install sfgroup安装软件组yum groups remove sfgroup卸载软件组

3.配置本地yum源

1.前提:有一台能够连上真机网络的虚拟机或虚拟机快照

2.获得与本机系统版本一致的镜像

查看系统版本:hostnamectl [root@localhost ~]# hostnamectl Static hostname: localhost.localdomain Icon name: computer-vm Chassis: vm Machine ID: c84d1e71dedd4a6494f7a8c4056b6643 Boot ID: 8d3382cd78aa4b13818adcf570a9fd5b Virtualization: kvm Operating System: Red Hat Enterprise Linux Server 7.3 (Maipo) CPE OS Name: cpe:/o:redhat:enterprise_linux:7.3:GA:server Kernel: Linux 3.10.0-514.el7.x86_64 Architecture: x86-64 从真机下载镜像: [root@localhost ~]# scp root@172.25.254.79:/home/kiosk/Desktop/rhel-server-7.3-x86_64-dvd.iso /mnt/ The authenticity of host '172.25.254.79 (172.25.254.79)' can't be established. ECDSA key fingerprint is b8:a2:3e:c2:23:27:52:59:36:0a:98:5d:e4:3a:26:0b. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '172.25.254.79' (ECDSA) to the list of known hosts. root@172.25.254.79's password: rhel-server-7.3-x86_64-dvd.iso 100% 3618MB 41.1MB/s 01:28

3.配置本地yum源

挂载镜像 [root@localhost ~]# mkdir /westos ##新建可挂载的目录 [root@localhost ~]# ls /mnt/ ##显示镜像名称 rhel-server-7.3-x86_64-dvd.iso [root@localhost ~]# mount /mnt/rhel-server-7.3-x86_64-dvd.iso /westos/ ##将镜像挂载到westos目录下 mount: /dev/loop0 is write-protected, mounting read-only [root@localhost ~]# cd /westos/ [root@localhost westos]# ls addons images Packages RPM-GPG-KEY-redhat-release EFI isolinux release-notes TRANS.TBL EULA LiveOS repodata GPL media.repo RPM-GPG-KEY-redhat-beta 设定永久挂载: vim /etc/rc.d/rc.local 编辑的内容为:mount /mnt/rhel-server-7.3-x86_64-dvd.iso /westos 给 /etc/rc.d/rc.local添加权限:chmod 755 /etc/rc.d/rc.local 开机自启动文件:/etc/rc.d/rc.local设定系统安装源指向 编辑 westos.repo的内容为: [westos]软件库的名字,任意写,仓库名称name=aaa软件库的描述信息,任意写 ,对软件源的描述baseurl=file:///westos软件安装访问地址, 网络安装源gpgcheck=0不让红帽公司检测这台虚拟机要下载的第三方软件是否授权,不检测gpgkeyenabled=1让以上操作生效,此安装源语句块生效

注意: file://为访问方式 /westos为访问目录,gpg是pgp的非商业版

[root@localhost westos]# cd /etc/yum.repos.d/ ##切换到/yum.repo.d/目录下 [root@localhost yum.repos.d]# vim westos.repo ##编辑的文件必须以.repo结尾 [root@localhost yum.repos.d]# yum clean all ##清除原有的yum源 Loaded plugins: langpacks, product-id, search-disabled-repos, subscription- : manager This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. Cleaning repos: westos Cleaning up everything [root@localhost yum.repos.d]# yum repolist ##列出仓库信息 Loaded plugins: langpacks, product-id, search-disabled-repos, subscription- : manager This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. westos | 4.1 kB 00:00 (1/2): westos/group_gz | 136 kB 00:00 (2/2): westos/primary_db | 3.9 MB 00:00 repo id repo name status westos aaa 4,751 repolist: 4,751

4.共享型yum源的部署

1.在一台已经配置好本地yum源的主机中安装httpd

yum install httpd

2.配置网络yum源

systemctl start httpd打开httpd服务systemctl enable httpd启用httpdsystemctl stop firewalld关闭火墙systemctl disable firewalld禁用防火墙mkdir /var/www/html/rhel7.3创建目录mount /mnt/rhel-server-7.3-x86_64-dvd.iso /var/www/html/rhel7.3挂载镜像vim /etc/rc.d/rc.local编辑文件,实现永久挂载chmod +x /etc/rc.d/rc.local添加权限vim /etc/yum.repos.d/westos.repo编辑yum源文件 [root@localhost yum.repos.d]# systemctl start httpd [root@localhost yum.repos.d]# systemctl enable httpd Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service. [root@localhost yum.repos.d]# systemctl stop firewalld [root@localhost yum.repos.d]# systemctl disable firewalld Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service. Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service. [root@localhost yum.repos.d]# netstat -antlupe | grep httpd tcp6 0 0 :::80 :::* LISTEN 0 41602 4431/httpd [root@localhost yum.repos.d]# cd /var/www/html/ [root@localhost html]# ls [root@localhost html]# mkdir /var/www/html/rhel7.3 [root@localhost html]# mount /mnt/rhel-server-7.3-x86_64-dvd.iso /var/www/html/rhel7.3 mount: /dev/loop1 is write-protected, mounting read-only [root@localhost ~]# vim /etc/rc.d/rc.local [root@localhost ~]# chmod +x /etc/rc.d/rc.local [root@localhost ~]# vim /etc/yum.repos.d/westos.repo 编辑 westos.repo的内容为: [westos] name=aaa baseurl=http://172.25.254.70/rhel7.3 gpgcheck=0 注意:将镜像挂载在 /var/www/html 下才能共享yum源

3.配置成功如下图所示:

5.第三方软件仓库的搭建

1.将所有的rpm包放到一个目录中

[root@localhost ~]# ls /software/ FluffyMcAwesome-A-6.4.0-11.r19335.x86_64.rpm FluffyMcAwesome-B-6.4.0-11.r19335.x86_64.rpm kolourpaint-4.10.5-4.el7.x86_64.rpm kolourpaint-libs-4.10.5-4.el7.x86_64.rpm linuxqq_2.0.0-b1-1024_x86_64.rpm wps-office-10.1.0.5672-1.a21.x86_64.rpm

2.createrepo -v /software/ 命令执行成功会生成repodate目录

[root@localhost ~]# createrepo -v /software/ [root@localhost ~]# ls /software/ FluffyMcAwesome-A-6.4.0-11.r19335.x86_64.rpm FluffyMcAwesome-B-6.4.0-11.r19335.x86_64.rpm kolourpaint-4.10.5-4.el7.x86_64.rpm kolourpaint-libs-4.10.5-4.el7.x86_64.rpm linuxqq_2.0.0-b1-1024_x86_64.rpm repodata wps-office-10.1.0.5672-1.a21.x86_64.rpm

3.vim /etc/yum.repos.d/westos.repo

[root@localhost ~]# cd /etc/yum.repos.d/ [root@localhost yum.repos.d]# ls redhat.repo westos.repo [root@localhost yum.repos.d]# vim westos.repo 编辑内容如下: [software] name=software baseurl=file:///software gpgcheck=0

4.查看yum list available

[root@localhost ~]# yum list available Loaded plugins: langpacks, product-id, search-disabled-repos, : subscription-manager This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. Available Packages FluffyMcAwesome-A.x86_64 6.4.0-11.r19335 software FluffyMcAwesome-B.x86_64 6.4.0-11.r19335 software kolourpaint.x86_64 4.10.5-4.el7 software kolourpaint-libs.x86_64 4.10.5-4.el7 software linuxqq.x86_64 2.0.0-b1 software wps-office.x86_64 10.1.0.5672-1.a21 software
最新回复(0)