Linux中應用程序的安裝于管理
一 . rpm安裝
1.掛載
光驅里面存放了很多rpm的軟件包
光驅在系統中使用時,需要掛載
mount /dev/cdrom /mnt/
cd /mnt
[root@stw mnt]# ls
CentOS_BuildTag GPL LiveOS RPM-GPG-KEY-CentOS-7
EFI images Packages RPM-GPG-KEY-CentOS-Testing-7
EULA isolinux repodata TRANS.TBL
[root@stw mnt]# cd Packages
[root@stw Packages]# ls
389-ds-base-1.3.8.4-15.el7.x86_64.rpm
389-ds-base-libs-1.3.8.4-15.el7.x86_64.rpm
abattis-cantarell-fonts-0.0.25-1.el7.noarch.rpm
abrt-2.1.11-52.el7.centos.x86_64.rpm
......
Packages包中存放了很多rpm的軟件包
2.rpm包管理命令
顯示系統中以RPM方式安裝的所有軟件列表
rpm -qa
查看某個軟件包是否安裝
rpm -q vsftpd
或者
rpm -qa | grep vsftpd
查看指定軟件包的詳細信息
[root@stw ~]# rpm -qi vsftpd
Name : vsftpd
Version : 3.0.2
Release : 29.el7_9
Architecture: x86_64
Install Date: Mon 28 Jul 2025 11:48:19 AM CST
Group : System Environment/Daemons
Size : 361349
License : GPLv2 with exceptions
Signature : RSA/SHA256, Fri 11 Jun 2021 11:06:15 PM CST, Key ID 24c6a8a7f4a80eb5
Source RPM : vsftpd-3.0.2-29.el7_9.src.rpm
Build Date : Thu 10 Jun 2021 12:15:50 AM CST
Build Host : x86-02.bsys.centos.org
Relocations : (not relocatable)
Packager : CentOS BuildSystem <http://bugs.centos.org>
Vendor : CentOS
URL : https://security.appspot.com/vsftpd.html
Summary : Very Secure Ftp Daemon
Description :
vsftpd is a Very Secure FTP daemon. It was written completely from
scratch.
顯示指定軟件包在當前系統中安裝的所有目錄和文件
(安裝了vsftpd這個軟件包之后會生成出來的所有目錄和文件)
[root@stw ~]# rpm -ql vsftpd
/etc/logrotate.d/vsftpd
/etc/pam.d/vsftpd
/etc/vsftpd
/etc/vsftpd/ftpusers
/etc/vsftpd/user_list
/etc/vsftpd/vsftpd.conf
......
查看指定的文件或目錄是哪個軟件包所安裝的
rpm -qf 文件或者目錄名
[root@stw ~]# rpm -qf /etc/logrotate.d/vsftpd
vsftpd-3.0.2-29.el7_9.x86_64
查詢未安裝的rpm軟件包信息
-qpi:查看指定軟件包的詳細信息----指定軟件包的路徑要明確
[root@stw ~]# rpm -qpi /mnt/Packages/vsftpd-3.0.2-25.el7.x86_64.rpm
Name : vsftpd
Version : 3.0.2
Release : 25.el7
Architecture: x86_64
Install Date: (not installed)
Group : System Environment/Daemons
Size : 361335
License : GPLv2 with exceptions
Signature : RSA/SHA256, Mon 12 Nov 2018 10:48:54 PM CST, Key ID 24c6a8a7f4a80eb5
Source RPM : vsftpd-3.0.2-25.el7.src.rpm
Build Date : Wed 31 Oct 2018 03:45:10 AM CST
Build Host : x86-01.bsys.centos.org
Relocations : (not relocatable)
Packager : CentOS BuildSystem <http://bugs.centos.org>
Vendor : CentOS
URL : https://security.appspot.com/vsftpd.html
Summary : Very Secure Ftp Daemon
Description :
vsftpd is a Very Secure FTP daemon. It was written completely from
scratch.
-qpl:查看該軟件包準備安裝的所有目標目錄和文件列表(這些目標目錄和文件列表還沒有存在)
[root@stw ~]# rpm -qpl /mnt/Packages/vsftpd-3.0.2-25.el7.x86_64.rpm
/etc/logrotate.d/vsftpd
/etc/pam.d/vsftpd
/etc/vsftpd
/etc/vsftpd/ftpusers
/etc/vsftpd/user_list
/etc/vsftpd/vsftpd.conf
/etc/vsftpd/vsftpd_conf_migrate.sh
......
rpm
-i 安裝 (內核的更新和安裝用-i)
-v 顯示詳細過程
-h 以“#”顯示進度
-e 卸載
-U 更新,如果該軟件包未安裝的話,則直接安裝最新版本
-F 更新,如果未安裝舊版本軟件包,則放棄安裝或更新
–force 強制
–nodeps 去除依賴性關系
卸載(rpm -e 軟件包名稱)
[root@stw ~]# rpm -e vsftpd
[root@stw ~]# rpm -q vsftpd
package vsftpd is not installed
二 . yum安裝
1.yum倉庫
yum倉庫必須在/etc/yum.repos.d/目錄下
cd /etc/yum.repos.d/
rm -rf *
vim server.repo
[a]
name=aa
baseurl=file:///mnt/ (本地安裝)
baseurl=http:// (網絡安裝)
enabled=1
gpgcheck=0(校驗完整性,1:開啟,0:關閉)
一般網絡安裝才需要校驗
gpgcheck=1(校驗完整性,1:開啟,0:關閉)
gpgkey =http://加上密鑰具體位置
[root@stw ~]# cd /etc/yum.repos.d/
[root@stw yum.repos.d]# ls
CentOS-Base.repo
[root@stw yum.repos.d]# rm -rf *
[root@stw yum.repos.d]# vim server.repo //server可以自己命名
2.yum命令
安裝軟件包(yum -y install 軟件包名)
[root@stw yum.repos.d]# yum -y install httpd
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
a | 3.6 kB 00:00
Package matching httpd-2.4.6-88.el7.centos.x86_64 already installed. Checking for update.
Nothing to do
卸載軟件包(yum -y remove 軟件包名)
[root@stw yum.repos.d]# yum -y remove httpd
Loaded plugins: fastestmirror, langpacks
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-99.el7.centos.1 will be erased
--> Finished Dependency Resolution
a | 3.6 kB 00:00 Dependencies Resolved================================================================================Package Arch Version Repository Size
================================================================================
Removing:httpd x86_64 2.4.6-99.el7.centos.1 @updates 9.4 MTransaction Summary
================================================================================
Remove 1 PackageInstalled size: 9.4 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transactionErasing : httpd-2.4.6-99.el7.centos.1.x86_64 1/1 Verifying : httpd-2.4.6-99.el7.centos.1.x86_64 1/1 Removed:httpd.x86_64 0:2.4.6-99.el7.centos.1 Complete!
安裝軟件包組(yum -y groupinstall "軟件包組 " )
[root@stw yum.repos.d]# yum -y groupinstall "Development Tools"
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Maybe run: yum groups mark install (see man yum)
No packages in any requested group available to install or update
卸載軟件包組(yum -y group remove “軟件包組”)
[root@stw yum.repos.d]# yum -y groupremove "Development Tools"
列出所有已安裝的和可用的軟件包(yum list)
列出所有已安裝的和可用的軟件包組(yum group list)
更新軟件包(yum update 軟件包)
查看yum倉庫是否配置成功(yum repolist)
[root@stw yum.repos.d]# yum repolist
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
repo id repo name status
a aa 4,021
repolist: 4,021
三 . dns安裝
dnf的使用方法基本上和yum一致(使用前要用yum網絡安裝dnf)
dnf -y install
dnf -y remove
dnf -y update
[root@stw yum.repos.d]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo% Total % Received % Xferd Average Speed Time Time Time CurrentDload Upload Total Spent Left Speed
100 2523 100 2523 0 0 8376 0 --:--:-- --:--:-- --:--:-- 8410
[root@stw yum.repos.d]# rpm -q dnf
package dnf is not installed
[root@stw yum.repos.d]# yum -y install dnf
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile* base: mirrors.aliyun.com* extras: mirrors.aliyun.com* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package dnf.noarch 0:4.0.9.2-2.el7_9 will be installed
--> Finished Dependency ResolutionDependencies Resolved================================================================================Package Arch Version Repository Size
================================================================================
Installing:dnf noarch 4.0.9.2-2.el7_9 extras 357 kTransaction Summary
================================================================================
Install 1 PackageTotal download size: 357 k
Installed size: 1.6 M
Downloading packages:
dnf-4.0.9.2-2.el7_9.noarch.rpm | 357 kB 00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transactionInstalling : dnf-4.0.9.2-2.el7_9.noarch 1/1 Verifying : dnf-4.0.9.2-2.el7_9.noarch 1/1 Installed:dnf.noarch 0:4.0.9.2-2.el7_9 Complete!
[root@stw yum.repos.d]# rpm -q dnf
dnf-4.0.9.2-2.el7_9.noarch
現在可以使用dnf
[root@stw yum.repos.d]# dnf -y install vsftpd
aa 78 MB/s | 4.8 MB 00:00
CentOS-7 - Base - mirrors.aliyun.com 0.0 B/s | 0 B 00:00
CentOS-7 - Updates - mirrors.aliyun.com 0.0 B/s | 0 B 00:00
CentOS-7 - Extras - mirrors.aliyun.com 0.0 B/s | 0 B 00:00
Dependencies resolved.
================================================================================Package Arch Version Repository Size
================================================================================
Installing:vsftpd x86_64 3.0.2-29.el7_9 updates 173 kTransaction Summary
================================================================================
Install 1 PackageTotal download size: 173 k
Installed size: 353 k
Downloading Packages:
vsftpd-3.0.2-29.el7_9.x86_64.rpm 1.4 MB/s | 173 kB 00:00
--------------------------------------------------------------------------------
Total 1.4 MB/s | 173 kB 00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transactionPreparing : 1/1 Installing : vsftpd-3.0.2-29.el7_9.x86_64 1/1 Running scriptlet: vsftpd-3.0.2-29.el7_9.x86_64 1/1 Verifying : vsftpd-3.0.2-29.el7_9.x86_64 1/1 Installed:vsftpd-3.0.2-29.el7_9.x86_64 Complete!