Linux下安裝與卸載
rpm工具使用
• 設置光驅並掛載
• rpm包格式,包名、版本號、發布版本號、平台
• rpm -ivh rpm包文件 //安裝
• rpm -Uvh rpm包文件 //升級
• rpm -e 包名 //卸載
• rpm -qa //查詢安裝的包
• rpm -q 包名 //查詢指定包是否安裝
• rpm -qi 包名 //查詢指定包信息
• rpm -ql 包名 //列出包安裝的文件
• rpm -qf 文件絕對路徑 //查看一個文件是由哪個包安裝的
設置光驅並掛載
1)設置光驅,在虛擬機右下角連接光驅。
2)設置光驅
[root@localhost ~]# mount /dev/cdrom /mnt
mount: /dev/sr0 寫保護,將以只讀方式掛載
查看
[root@localhost ~]# ls /mnt
CentOS_BuildTag GPL LiveOS RPM-GPG-KEY-CentOS-7
EFI images Packages RPM-GPG-KEY-CentOS-Testing-7
EULA isolinux repodata TRANS.TBL
3)/mnt/Packages目錄里面是rpm包
[root@localhost ~]# ls /mnt/Packages/ |head -5
389-ds-base-1.3.5.10-11.el7.x86_64.rpm
389-ds-base-libs-1.3.5.10-11.el7.x86_64.rpm
abattis-cantarell-fonts-0.0.16-3.el7.noarch.rpm
abrt-2.1.11-45.el7.centos.x86_64.rpm
abrt-addon-ccpp-2.1.11-45.el7.centos.x86_64.rpm
4)注解:
每個rpm包的名稱都是由-和.分成若干部分,比如abrt-2.1.11-45.el7.centos.x86_64.rpm Abrt:包名2.1.11-45:版本號;2為主版本號,1為次版本號,11為修正版本
45-el7.centos:發布版本號x86_64.:運行平台,64位 cpu目前分32位和64位,i386、i586、i686是32位,X86_64是64位。64位系統可以安裝32位軟件,但是32位系統不能安裝64為軟件。
安裝rpm包:
rpm -ivh rpm包文件 //安裝
-i:表示安裝
-v:表示可視化
-h:表示顯示安裝進度
--force:表示強制安裝,即使覆蓋屬於其他包的文件也要安裝
--nodeps:表示當要安裝的rpm包依賴於其他包時,即使其他包沒有安裝,也要安裝這個包
[root@localhost ~]# cd /mnt/Packages/
[root@localhost Packages]# rpm -ivh xz-5.2.2-1.el7.x86_64.rpm
准備中... ################################# [100%]
軟件包 xz-5.2.2-1.el7.x86_64 已經安裝
升級rpm包
命令:rpm -Uvh rpm 包文件
-U:表示升級
卸載rpm包
命令:rpm –e 包名
[root@localhost Packages]# rpm -e xz
錯誤:依賴檢測失敗:
xz 被 (已安裝) dracut-033-463.el7.x86_64 需要
/usr/bin/xz 被 (已安裝) kmod-20-9.el7.x86_64 需要
查詢當前系統所有已經安裝的包
命令:rpm –qa
[root@localhost Packages]# rpm -qa |head
trousers-0.3.13-1.el7.x86_64
filesystem-3.2-21.el7.x86_64
net-tools-2.0-0.17.20131004git.el7.x86_64
bind-license-9.9.4-37.el7.noarch
fxload-2002_04_11-16.el7.x86_64
nss-softokn-freebl-3.16.2.3-14.4.el7.x86_64
libthai-0.1.14-9.el7.x86_64
ncurses-libs-5.9-13.20130511.el7.x86_64
libX11-common-1.6.3-3.el7.noarch
libselinux-2.5-6.el7.x86_64
查詢指定包是否安裝
rpm -q 包名 //
[root@localhost Packages]# rpm -q lvm2
lvm2-2.02.130-5.el7.x86_64
查詢指定包的信息
命令:rpm –qi 包名
[root@localhost Packages]# rpm -qi tree
Name : tree
Version : 1.6.0
Release : 10.el7
Architecture: x86_64
Install Date: 2017年10月20日 星期五 15時00分08秒
Group : Applications/File
Size : 89505
License : GPLv2+
Signature : RSA/SHA256, 2014年07月04日 星期五 13時36分46秒, Key ID 24c6a8a7f4a80eb5
Source RPM : tree-1.6.0-10.el7.src.rpm
Build Date : 2014年06月10日 星期二 03時28分53秒
Build Host : worker1.bsys.centos.org
Relocations : (not relocatable)
Packager : CentOS BuildSystem <http://bugs.centos.org>
Vendor : CentOS
URL : http://mama.indstate.edu/users/ice/tree/
Summary : File system tree viewer
Description :
The tree utility recursively displays the contents of directories in a
tree-like format. Tree is basically a UNIX port of the DOS tree
utility.
列出一個rpm包的安裝文件
命令:rpm –ql 包名
[root@localhost Packages]# rpm -ql tree
/usr/bin/tree
/usr/share/doc/tree-1.6.0
/usr/share/doc/tree-1.6.0/LICENSE
/usr/share/doc/tree-1.6.0/README
/usr/share/man/man1/tree.1.gz
查看這個文件是由哪個包安裝的
命令:rpm –qf 絕對路徑
[root@localhost Packages]# rpm -qf /usr/bin/cd
bash-4.2.46-20.el7_2.x86_64
[root@localhost Packages]# rpm -qf `which cd`
bash-4.2.46-20.el7_2.x86_64
注意:``里面which cd 顯示只有一行,如果是which ls 顯示2行,這里就不能使用這條命令。
列出所有可用的rpm包
列出所有可用的rpm包
yum工具
yum list //列出可用rpm包
ls /etc/yum.repos.d/
yum search vim //搜索包
yum install [-y]
yum grouplist
yum groupinstall [-y]
yum remove [-y]
yum update [-y]
yum provides “/*/vim”
列出可用rpm包
命令yum list
[root@localhost Packages]# yum list |head -20
已加載插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.btte.net
* extras: mirrors.btte.net
* updates: mirrors.btte.net
已安裝的軟件包
GeoIP.x86_64 1.5.0-11.el7 @anaconda
NetworkManager.x86_64 1:1.4.0-12.el7 @anaconda
NetworkManager-libnm.x86_64 1:1.4.0-12.el7 @anaconda
NetworkManager-team.x86_64 1:1.4.0-12.el7 @anaconda
NetworkManager-tui.x86_64 1:1.4.0-12.el7 @anaconda
NetworkManager-wifi.x86_64 1:1.4.0-12.el7 @anaconda
acl.x86_64 2.2.51-12.el7 @anaconda
aic94xx-firmware.noarch 30-6.el7 @anaconda
alsa-firmware.noarch 1.0.28-2.el7 @anaconda
alsa-lib.x86_64 1.1.1-1.el7 @anaconda
alsa-tools-firmware.x86_64 1.1.0-1.el7 @anaconda
atk.x86_64 2.14.0-1.el7 @anaconda
atkmm.x86_64 2.22.7-3.el7 @anaconda
audit.x86_64 2.6.5-3.el7 @anaconda
左邊是包名,中間是版本信息,右邊是倉庫名,倉庫這邊顯示@base、@anaconda表示已經安裝。如果未安裝這顯示base或者anaconda,如果是updates表示已安裝但是需要升級。
搜索包
yum search vim
[root@localhost Packages]# yum search vim
已加載插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.neusoft.edu.cn
* extras: mirrors.neusoft.edu.cn
* updates: mirrors.neusoft.edu.cn
=============================== N/S matched: vim ===============================
protobuf-vim.x86_64 : Vim syntax highlighting for Google Protocol Buffers
: descriptions
vim-X11.x86_64 : The VIM version of the vi editor for the X Window System
vim-common.x86_64 : The common files needed by any version of the VIM editor
vim-enhanced.x86_64 : A version of the VIM editor which includes recent
: enhancements
vim-filesystem.x86_64 : VIM filesystem layout
vim-minimal.x86_64 : A minimal version of the VIM editor
名稱和簡介匹配 only,使用“search all”試試。
安裝rpm包
yum install [-y]
[root@localhost Packages]# yum install -y tree
已加載插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.btte.net
* extras: mirrors.btte.net
* updates: mirrors.btte.net
正在解決依賴關系
--> 正在檢查事務
---> 軟件包 tree.x86_64.0.1.6.0-10.el7 將被 安裝
--> 解決依賴關系完成
依賴關系解決
=================================================================================
Package 架構 版本 源 大小
=================================================================================
正在安裝:
tree x86_64 1.6.0-10.el7 base 46 k
事務概要
=================================================================================
安裝 1 軟件包
總下載量:46 k
安裝大小:87 k
Downloading packages:
tree-1.6.0-10.el7.x86_64.rpm | 46 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安裝 : tree-1.6.0-10.el7.x86_64 1/1
驗證中 : tree-1.6.0-10.el7.x86_64 1/1
已安裝:
tree.x86_64 0:1.6.0-10.el7
完畢!
列出套件
命令:yum grouplist
[root@localhost Packages]# yum grouplist
已加載插件:fastestmirror
沒有安裝組信息文件
Maybe run: yum groups mark convert (see man yum)
Loading mirror speeds from cached hostfile
* base: mirrors.btte.net
* extras: mirrors.btte.net
* updates: mirrors.btte.net
可用的環境分組:
最小安裝
基礎設施服務器
計算節點
文件及打印服務器
基本網頁服務器
虛擬化主機
帶 GUI 的服務器
GNOME 桌面
KDE Plasma Workspaces
開發及生成工作站
可用組:
傳統 UNIX 兼容性
兼容性程序庫
圖形管理工具
安全性工具
開發工具
控制台互聯網工具
智能卡支持
科學記數法支持
系統管理
系統管理工具
完成
安裝套件
命令:yum groupinstall –y 套件名
升級rpm包
命令:yum update –y 包名 注意:如果不加包名,會把系統所有的包包括系統本身升級。
卸載rpm包
命令:yum remove –y 包名
[root@localhost Packages]# yum remove -y tree
已加載插件:fastestmirror
正在解決依賴關系
--> 正在檢查事務
---> 軟件包 tree.x86_64.0.1.6.0-10.el7 將被 刪除
--> 解決依賴關系完成
依賴關系解決
=================================================================================
Package 架構 版本 源 大小
=================================================================================
正在刪除:
tree x86_64 1.6.0-10.el7 @base 87 k
事務概要
=================================================================================
移除 1 軟件包
安裝大小:87 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在刪除 : tree-1.6.0-10.el7.x86_64 1/1
驗證中 : tree-1.6.0-10.el7.x86_64 1/1
刪除:
tree.x86_64 0:1.6.0-10.el7
完畢!
搜索一個命令是那個包安裝的
yum provides “/*/vim
yum本地倉庫
掛載鏡像到/mnt目錄
#mount /dev/cdrom /mnt
刪除/etc/yum.repos.d目錄下的所有repo文件(刪除之前最好先備份)。
#cp -r /etc/yum.repos.d /etc/yum.repos.d.back
#rm -f /etc/yum.repos.d/*
創建新文件dvd.repo。
#vim /etc/yum.repos.d/dvd.repo //加入以下內容
[dvd]
name=install dvd
baseurl=file://mnt
enabled=1
gpgcheck=0
重置
#yum clean all
生成緩存
#yum list
更換yum倉庫源
進入yum倉庫
#cd /etc/yum.repos.d/
刪除之前我們設置的本地源dvd.repo
[root@localhost]# rm dvd.repo
rm:是否刪除普通文件"dvd.repo"?y
使用wget下載需要安裝wget包
[root@localhost]# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
或者curl –O 來下載
[root@localhost]# curl -O http://mirrors.163.com/.help/CentOS7-Base-163.repo
生成緩存
[root@localhost] #yumlist
安裝擴展源epel
yum install -y epel-release
yum list |grep epel
[root@localhost yum.repos.d]# yum list |grep epel|head -15
* epel: ftp.cuhk.edu.hk
epel-release.noarch 7-9 @extras
0ad.x86_64 0.0.22-1.el7 epel
0ad-data.noarch 0.0.22-1.el7 epel
0install.x86_64 2.11-1.el7 epel
2048-cli.x86_64 0.9.1-1.el7 epel
2048-cli-nocurses.x86_64 0.9.1-1.el7 epel
2ping.noarch 3.2.1-2.el7 epel
389-admin.x86_64 1.1.46-1.el7 epel
389-admin-console.noarch 1.1.12-1.el7 epel
389-admin-console-doc.noarch 1.1.12-1.el7 epel
389-adminutil.x86_64 1.1.21-2.el7 epel
389-adminutil-devel.x86_64 1.1.21-2.el7 epel
389-console.noarch 1.1.18-1.el7 epel
389-ds.noarch 1.2.2-6.el7 epel
yum下載rpm包
yum install -y 包名 --downloadonly
ls /var/cache/yum/x86_64/7/
yum install -y 包名 --downloadonly --downloaddir=路徑
yum reinstall -y 包名 --downloadonly --downloaddir=路徑
只下載而不安裝
有時候我們需要下載rpm包,而僅僅是復制給其他機器使用,yum工具安裝rpm包時,首先下載這個rpm包,然后再去安裝,所以我們可以做到只下載而不安裝。
[root@localhost yum.repos.d]# yum install -y 2ping.noarch --downloadonly
已加載插件:fastestmirror
Loading mirror speeds from cached hostfile
* epel: ftp.cuhk.edu.hk
正在解決依賴關系
--> 正在檢查事務
---> 軟件包 2ping.noarch.0.3.2.1-2.el7 將被 安裝
--> 解決依賴關系完成
依賴關系解決
=================================================================================
Package 架構 版本 源 大小
=================================================================================
正在安裝:
2ping noarch 3.2.1-2.el7 epel 62 k
事務概要
=================================================================================
安裝 1 軟件包
總下載量:62 k
安裝大小:204 k
Background downloading packages, then exiting:
警告:/var/cache/yum/x86_64/7/epel/packages/2ping-3.2.1-2.el7.noarch.rpm.2289.tmp: 頭V3 RSA/SHA256 Signature, 密鑰 ID 352c64e5: NOKEY
2ping-3.2.1-2.el7.noarch.rpm.2289.tmp 的公鑰尚未安裝
2ping-3.2.1-2.el7.noarch.rpm | 62 kB 00:00:01
exiting because "Download Only" specified
查看下載的rpm包
ls /var/cache/yum/x86_64/7
注釋:
yum默認下載到/var/cache/yum/x86_64/7/XXX/packages/ 下面;這里的XXX指的是base,updates,epel等,它跟yum list最右側的字符串一致。
[[root@localhost yum.repos.d]# ls /var/cache/yum/x86_64/7/epel/packages/
2ping-3.2.1-2.el7.noarch.rpm zmap-2.1.1-1.el7.x86_64.rpm
hiredis-0.12.1-1.el7.x86_64.rpm
下載到指定的目錄下
yum install -y 包名 --downloadonly --downloaddir=路徑
[root@localhost yum.repos.d]# yum install -y zmap --downloadonly --downloaddir=/tmp/
已加載插件:fastestmirror
Loading mirror speeds from cached hostfile
* epel: ftp.cuhk.edu.hk
正在解決依賴關系
--> 正在檢查事務
---> 軟件包 zmap.x86_64.0.2.1.1-1.el7 將被 安裝
--> 正在處理依賴關系 libhiredis.so.0.12()(64bit),它被軟件包 zmap-2.1.1-1.el7.x86_64 需要
--> 正在檢查事務
---> 軟件包 hiredis.x86_64.0.0.12.1-1.el7 將被 安裝
--> 解決依賴關系完成
依賴關系解決
================================================================================================
Package 架構 版本 源 大小
================================================================================================
正在安裝:
zmap x86_64 2.1.1-1.el7 epel 124 k
為依賴而安裝:
hiredis x86_64 0.12.1-1.el7 epel 29 k
事務概要
================================================================================================
安裝 1 軟件包 (+1 依賴軟件包)
總下載量:154 k
安裝大小:378 k
Background downloading packages, then exiting:
exiting because "Download Only" specified
[root@localhost yum.repos.d]# ls /tmp
1.txt.bz2
1.txt.gz
1.txt.xz
222
hiredis-0.12.1-1.el7.x86_64.rpm
systemd-private-7d28b5738df345b0bb18e85cef932021-vmtoolsd.service-43orfA
test
yum_save_tx.2017-11-14.23-50.Av9TET.yumtx
yum_save_tx.2017-11-14.23-50.ClMWHy.yumtx
yum_save_tx.2017-11-14.23-56.v0Q9N8.yumtx
zmap-2.1.1-1.el7.x86_64.rpm
如果已經安裝過的包使用—downloadnoly就不起作用了,他會提示這個包已經安裝過了,根本下載不下來
下載已經安裝過過的RPM包
yum reinstall -y 包名 --downloadonly --downloaddir=路徑
[root@localhost yum.repos.d]# yum reinstall -y tree --downloadonly --downloaddir=/tmp/
已加載插件:fastestmirror
Loading mirror speeds from cached hostfile
* epel: ftp.cuhk.edu.hk
正在解決依賴關系
--> 正在檢查事務
---> 軟件包 tree.x86_64.0.1.6.0-10.el7 將被 已重新安裝
--> 解決依賴關系完成
依賴關系解決
================================================================================================
Package 架構 版本 源 大小
================================================================================================
重新安裝:
tree x86_64 1.6.0-10.el7 base 46 k
事務概要
================================================================================================
重新安裝 1 軟件包
總下載量:46 k
安裝大小:87 k
Background downloading packages, then exiting:
tree-1.6.0-10.el7.x86_64.rpm | 46 kB 00:00:00
exiting because "Download Only" specified
[root@localhost yum.repos.d]# ls /tmp/
1.txt.bz2
1.txt.gz
1.txt.xz
222
hiredis-0.12.1-1.el7.x86_64.rpm
systemd-private-7d28b5738df345b0bb18e85cef932021-vmtoolsd.service-43orfA
test
tree-1.6.0-10.el7.x86_64.rpm
源碼包安裝
cd /usr/local/src/
wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.2.32.tar.gz
tar zxvf httpd-2.2.32.tar.gz
cd httpd-2.2.32
./configure --prefix=/usr/local/apache2
make
make install
卸載就是刪除安裝的文件
進入本地
#cd /usr/local/src/
下載源碼包
wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.2.32.tar.gz
[root@localhost yum.repos.d]# cd /usr/local/src/
[root@localhost src]# wget https://mirrors.cnnic.cn/apache/httpd/httpd-2.2.34.tar.gz
--2017-11-15 00:26:41-- https://mirrors.cnnic.cn/apache/httpd/httpd-2.2.34.tar.gz
正在解析主機 mirrors.cnnic.cn (mirrors.cnnic.cn)... 101.6.6.177, 2402:f000:1:416:101:6:6:177
正在連接 mirrors.cnnic.cn (mirrors.cnnic.cn)|101.6.6.177|:443... 已連接。
已發出 HTTP 請求,正在等待回應... 200 OK
長度:7684419 (7.3M) [application/octet-stream]
正在保存至: “httpd-2.2.34.tar.gz”
100%[======================================================>] 7,684,419 1.20MB/s 用時 7.3s
2017-11-15 00:26:49 (1.00 MB/s) - 已保存 “httpd-2.2.34.tar.gz” [7684419/7684419])
[root@localhost src]# ls
httpd-2.2.34.tar.gz
解包
tar zxvf httpd-2.2.32.tar.gz
[root@localhost httpd-2.2.34]# tar -zxvf httpd-2.2.34.tar.gz
[root@localhost src]# ls
httpd-2.2.34 httpd-2.2.34.tar.gz
[root@localhost src]# cd httpd-2.2.34
[root@localhost httpd-2.2.34]# ls
ABOUT_APACHE CHANGES httpd.dsp libhttpd.dep NOTICE server
acinclude.m4 config.layout httpd.mak libhttpd.dsp NWGNUmakefile srclib
Apache.dsw configure httpd.spec libhttpd.mak os support
build configure.in include LICENSE README test
BuildAll.dsp docs INSTALL Makefile.in README.platforms VERSIONING
BuildBin.dsp emacs-style InstallBin.dsp Makefile.win README-win32.txt
buildconf httpd.dep LAYOUT modules ROADMAP
配置相關的選項並生成Makefile
cd httpd-2.2.32
/configure --prefix=/usr/local/apache2
[root@localhost httpd-2.2.34]# cd httpd-2.2.32
[root@localhost src]# /configure --prefix=/usr/local/apache2
checkingfor chosen layout... Apache
checkingfor working mkdir -p... yes
checkingbuild system type... x86_64-unknown-linux-gnu
checkinghost system type... x86_64-unknown-linux-gnu
checkingtarget system type... x86_64-unknown-linux-gnu
ConfiguringApache Portable Runtime library ...
checkingfor APR... reconfig
configuringpackage in srclib/apr now
checkingbuild system type... x86_64-unknown-linux-gnu
checkinghost system type... x86_64-unknown-linux-gnu
checkingtarget system type... x86_64-unknown-linux-gnu
ConfiguringAPR library
Platform: x86_64-unknown-linux-gnu
checkingfor working mkdir -p... yes
APRVersion: 1.5.2
checkingfor chosen layout... apr
checkingfor gcc... no
checkingfor cc... no
checkingfor cl.exe... no
configure: error: in `/usr/local/src/httpd-2.2.34/srclib/apr':
configure: error: no acceptable C compiler found in $PATH
See`config.log' for more details
configurefailed for srclib/apr
進行編譯
[root@localhost httpd-2.2.34]# make
執行完后可以echo $? ,0表示正常
[root@localhost httpd-2.2.34]# echo $?
0
安裝
make install
[root@localhost httpd-2.2.34]# make install
執行完后可以echo $? ,0表示正常
[root@localhost httpd-2.2.34]# echo $?
0
查看apache2目錄
[root@localhost httpd-2.2.34]# ls /usr/local/apache2/
bin build cgi-bin conf error htdocs icons include lib logs man manual modules
Linux下安裝與卸載
rpm工具使用
• 設置光驅並掛載
• rpm包格式,包名、版本號、發布版本號、平台
• rpm -ivh rpm包文件 //安裝
• rpm -Uvh rpm包文件 //升級
• rpm -e 包名 //卸載
• rpm -qa //查詢安裝的包
• rpm -q 包名 //查詢指定包是否安裝
• rpm -qi 包名 //查詢指定包信息
• rpm -ql 包名 //列出包安裝的文件
• rpm -qf 文件絕對路徑 //查看一個文件是由哪個包安裝的
設置光驅並掛載
1)設置光驅,在虛擬機右下角連接光驅。
2)設置光驅
[root@localhost ~]# mount /dev/cdrom /mnt
mount: /dev/sr0 寫保護,將以只讀方式掛載
查看
[root@localhost ~]# ls /mnt
CentOS_BuildTag GPL LiveOS RPM-GPG-KEY-CentOS-7
EFI images Packages RPM-GPG-KEY-CentOS-Testing-7
EULA isolinux repodata TRANS.TBL
3)/mnt/Packages目錄里面是rpm包
[root@localhost ~]# ls /mnt/Packages/ |head -5
389-ds-base-1.3.5.10-11.el7.x86_64.rpm
389-ds-base-libs-1.3.5.10-11.el7.x86_64.rpm
abattis-cantarell-fonts-0.0.16-3.el7.noarch.rpm
abrt-2.1.11-45.el7.centos.x86_64.rpm
abrt-addon-ccpp-2.1.11-45.el7.centos.x86_64.rpm
4)注解:
每個rpm包的名稱都是由-和.分成若干部分,比如abrt-2.1.11-45.el7.centos.x86_64.rpm Abrt:包名2.1.11-45:版本號;2為主版本號,1為次版本號,11為修正版本
45-el7.centos:發布版本號x86_64.:運行平台,64位 cpu目前分32位和64位,i386、i586、i686是32位,X86_64是64位。64位系統可以安裝32位軟件,但是32位系統不能安裝64為軟件。
安裝rpm包:
rpm -ivh rpm包文件 //安裝
-i:表示安裝
-v:表示可視化
-h:表示顯示安裝進度
--force:表示強制安裝,即使覆蓋屬於其他包的文件也要安裝
--nodeps:表示當要安裝的rpm包依賴於其他包時,即使其他包沒有安裝,也要安裝這個包
[root@localhost ~]# cd /mnt/Packages/
[root@localhost Packages]# rpm -ivh xz-5.2.2-1.el7.x86_64.rpm
准備中... ################################# [100%]
軟件包 xz-5.2.2-1.el7.x86_64 已經安裝
升級rpm包
命令:rpm -Uvh rpm 包文件
-U:表示升級
卸載rpm包
命令:rpm –e 包名
[root@localhost Packages]# rpm -e xz
錯誤:依賴檢測失敗:
xz 被 (已安裝) dracut-033-463.el7.x86_64 需要
/usr/bin/xz 被 (已安裝) kmod-20-9.el7.x86_64 需要
查詢當前系統所有已經安裝的包
命令:rpm –qa
[root@localhost Packages]# rpm -qa |head
trousers-0.3.13-1.el7.x86_64
filesystem-3.2-21.el7.x86_64
net-tools-2.0-0.17.20131004git.el7.x86_64
bind-license-9.9.4-37.el7.noarch
fxload-2002_04_11-16.el7.x86_64
nss-softokn-freebl-3.16.2.3-14.4.el7.x86_64
libthai-0.1.14-9.el7.x86_64
ncurses-libs-5.9-13.20130511.el7.x86_64
libX11-common-1.6.3-3.el7.noarch
libselinux-2.5-6.el7.x86_64
查詢指定包是否安裝
rpm -q 包名 //
[root@localhost Packages]# rpm -q lvm2
lvm2-2.02.130-5.el7.x86_64
查詢指定包的信息
命令:rpm –qi 包名
[root@localhost Packages]# rpm -qi tree
Name : tree
Version : 1.6.0
Release : 10.el7
Architecture: x86_64
Install Date: 2017年10月20日 星期五 15時00分08秒
Group : Applications/File
Size : 89505
License : GPLv2+
Signature : RSA/SHA256, 2014年07月04日 星期五 13時36分46秒, Key ID 24c6a8a7f4a80eb5
Source RPM : tree-1.6.0-10.el7.src.rpm
Build Date : 2014年06月10日 星期二 03時28分53秒
Build Host : worker1.bsys.centos.org
Relocations : (not relocatable)
Packager : CentOS BuildSystem <http://bugs.centos.org>
Vendor : CentOS
URL : http://mama.indstate.edu/users/ice/tree/
Summary : File system tree viewer
Description :
The tree utility recursively displays the contents of directories in a
tree-like format. Tree is basically a UNIX port of the DOS tree
utility.
列出一個rpm包的安裝文件
命令:rpm –ql 包名
[root@localhost Packages]# rpm -ql tree
/usr/bin/tree
/usr/share/doc/tree-1.6.0
/usr/share/doc/tree-1.6.0/LICENSE
/usr/share/doc/tree-1.6.0/README
/usr/share/man/man1/tree.1.gz
查看這個文件是由哪個包安裝的
命令:rpm –qf 絕對路徑
[root@localhost Packages]# rpm -qf /usr/bin/cd
bash-4.2.46-20.el7_2.x86_64
[root@localhost Packages]# rpm -qf `which cd`
bash-4.2.46-20.el7_2.x86_64
注意:``里面which cd 顯示只有一行,如果是which ls 顯示2行,這里就不能使用這條命令。
列出所有可用的rpm包
列出所有可用的rpm包
yum工具
yum list //列出可用rpm包
ls /etc/yum.repos.d/
yum search vim //搜索包
yum install [-y]
yum grouplist
yum groupinstall [-y]
yum remove [-y]
yum update [-y]
yum provides “/*/vim”
列出可用rpm包
命令yum list
[root@localhost Packages]# yum list |head -20
已加載插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.btte.net
* extras: mirrors.btte.net
* updates: mirrors.btte.net
已安裝的軟件包
GeoIP.x86_64 1.5.0-11.el7 @anaconda
NetworkManager.x86_64 1:1.4.0-12.el7 @anaconda
NetworkManager-libnm.x86_64 1:1.4.0-12.el7 @anaconda
NetworkManager-team.x86_64 1:1.4.0-12.el7 @anaconda
NetworkManager-tui.x86_64 1:1.4.0-12.el7 @anaconda
NetworkManager-wifi.x86_64 1:1.4.0-12.el7 @anaconda
acl.x86_64 2.2.51-12.el7 @anaconda
aic94xx-firmware.noarch 30-6.el7 @anaconda
alsa-firmware.noarch 1.0.28-2.el7 @anaconda
alsa-lib.x86_64 1.1.1-1.el7 @anaconda
alsa-tools-firmware.x86_64 1.1.0-1.el7 @anaconda
atk.x86_64 2.14.0-1.el7 @anaconda
atkmm.x86_64 2.22.7-3.el7 @anaconda
audit.x86_64 2.6.5-3.el7 @anaconda
左邊是包名,中間是版本信息,右邊是倉庫名,倉庫這邊顯示@base、@anaconda表示已經安裝。如果未安裝這顯示base或者anaconda,如果是updates表示已安裝但是需要升級。
搜索包
yum search vim
[root@localhost Packages]# yum search vim
已加載插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.neusoft.edu.cn
* extras: mirrors.neusoft.edu.cn
* updates: mirrors.neusoft.edu.cn
=============================== N/S matched: vim ===============================
protobuf-vim.x86_64 : Vim syntax highlighting for Google Protocol Buffers
: descriptions
vim-X11.x86_64 : The VIM version of the vi editor for the X Window System
vim-common.x86_64 : The common files needed by any version of the VIM editor
vim-enhanced.x86_64 : A version of the VIM editor which includes recent
: enhancements
vim-filesystem.x86_64 : VIM filesystem layout
vim-minimal.x86_64 : A minimal version of the VIM editor
名稱和簡介匹配 only,使用“search all”試試。
安裝rpm包
yum install [-y]
[root@localhost Packages]# yum install -y tree
已加載插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.btte.net
* extras: mirrors.btte.net
* updates: mirrors.btte.net
正在解決依賴關系
--> 正在檢查事務
---> 軟件包 tree.x86_64.0.1.6.0-10.el7 將被 安裝
--> 解決依賴關系完成
依賴關系解決
=================================================================================
Package 架構 版本 源 大小
=================================================================================
正在安裝:
tree x86_64 1.6.0-10.el7 base 46 k
事務概要
=================================================================================
安裝 1 軟件包
總下載量:46 k
安裝大小:87 k
Downloading packages:
tree-1.6.0-10.el7.x86_64.rpm | 46 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安裝 : tree-1.6.0-10.el7.x86_64 1/1
驗證中 : tree-1.6.0-10.el7.x86_64 1/1
已安裝:
tree.x86_64 0:1.6.0-10.el7
完畢!
列出套件
命令:yum grouplist
[root@localhost Packages]# yum grouplist
已加載插件:fastestmirror
沒有安裝組信息文件
Maybe run: yum groups mark convert (see man yum)
Loading mirror speeds from cached hostfile
* base: mirrors.btte.net
* extras: mirrors.btte.net
* updates: mirrors.btte.net
可用的環境分組:
最小安裝
基礎設施服務器
計算節點
文件及打印服務器
基本網頁服務器
虛擬化主機
帶 GUI 的服務器
GNOME 桌面
KDE Plasma Workspaces
開發及生成工作站
可用組:
傳統 UNIX 兼容性
兼容性程序庫
圖形管理工具
安全性工具
開發工具
控制台互聯網工具
智能卡支持
科學記數法支持
系統管理
系統管理工具
完成
安裝套件
命令:yum groupinstall –y 套件名
升級rpm包
命令:yum update –y 包名 注意:如果不加包名,會把系統所有的包包括系統本身升級。
卸載rpm包
命令:yum remove –y 包名
[root@localhost Packages]# yum remove -y tree
已加載插件:fastestmirror
正在解決依賴關系
--> 正在檢查事務
---> 軟件包 tree.x86_64.0.1.6.0-10.el7 將被 刪除
--> 解決依賴關系完成
依賴關系解決
=================================================================================
Package 架構 版本 源 大小
=================================================================================
正在刪除:
tree x86_64 1.6.0-10.el7 @base 87 k
事務概要
=================================================================================
移除 1 軟件包
安裝大小:87 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在刪除 : tree-1.6.0-10.el7.x86_64 1/1
驗證中 : tree-1.6.0-10.el7.x86_64 1/1
刪除:
tree.x86_64 0:1.6.0-10.el7
完畢!
搜索一個命令是那個包安裝的
yum provides “/*/vim
yum本地倉庫
掛載鏡像到/mnt目錄
#mount /dev/cdrom /mnt
刪除/etc/yum.repos.d目錄下的所有repo文件(刪除之前最好先備份)。
#cp -r /etc/yum.repos.d /etc/yum.repos.d.back
#rm -f /etc/yum.repos.d/*
創建新文件dvd.repo。
#vim /etc/yum.repos.d/dvd.repo //加入以下內容
[dvd]
name=install dvd
baseurl=file://mnt
enabled=1
gpgcheck=0
重置
#yum clean all
生成緩存
#yum list
更換yum倉庫源
進入yum倉庫
#cd /etc/yum.repos.d/
刪除之前我們設置的本地源dvd.repo
[root@localhost]# rm dvd.repo
rm:是否刪除普通文件"dvd.repo"?y
使用wget下載需要安裝wget包
[root@localhost]# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
或者curl –O 來下載
[root@localhost]# curl -O http://mirrors.163.com/.help/CentOS7-Base-163.repo
生成緩存
[root@localhost] #yumlist
安裝擴展源epel
yum install -y epel-release
yum list |grep epel
[root@localhost yum.repos.d]# yum list |grep epel|head -15
* epel: ftp.cuhk.edu.hk
epel-release.noarch 7-9 @extras
0ad.x86_64 0.0.22-1.el7 epel
0ad-data.noarch 0.0.22-1.el7 epel
0install.x86_64 2.11-1.el7 epel
2048-cli.x86_64 0.9.1-1.el7 epel
2048-cli-nocurses.x86_64 0.9.1-1.el7 epel
2ping.noarch 3.2.1-2.el7 epel
389-admin.x86_64 1.1.46-1.el7 epel
389-admin-console.noarch 1.1.12-1.el7 epel
389-admin-console-doc.noarch 1.1.12-1.el7 epel
389-adminutil.x86_64 1.1.21-2.el7 epel
389-adminutil-devel.x86_64 1.1.21-2.el7 epel
389-console.noarch 1.1.18-1.el7 epel
389-ds.noarch 1.2.2-6.el7 epel
yum下載rpm包
yum install -y 包名 --downloadonly
ls /var/cache/yum/x86_64/7/
yum install -y 包名 --downloadonly --downloaddir=路徑
yum reinstall -y 包名 --downloadonly --downloaddir=路徑
只下載而不安裝
有時候我們需要下載rpm包,而僅僅是復制給其他機器使用,yum工具安裝rpm包時,首先下載這個rpm包,然后再去安裝,所以我們可以做到只下載而不安裝。
[root@localhost yum.repos.d]# yum install -y 2ping.noarch --downloadonly
已加載插件:fastestmirror
Loading mirror speeds from cached hostfile
* epel: ftp.cuhk.edu.hk
正在解決依賴關系
--> 正在檢查事務
---> 軟件包 2ping.noarch.0.3.2.1-2.el7 將被 安裝
--> 解決依賴關系完成
依賴關系解決
=================================================================================
Package 架構 版本 源 大小
=================================================================================
正在安裝:
2ping noarch 3.2.1-2.el7 epel 62 k
事務概要
=================================================================================
安裝 1 軟件包
總下載量:62 k
安裝大小:204 k
Background downloading packages, then exiting:
警告:/var/cache/yum/x86_64/7/epel/packages/2ping-3.2.1-2.el7.noarch.rpm.2289.tmp: 頭V3 RSA/SHA256 Signature, 密鑰 ID 352c64e5: NOKEY
2ping-3.2.1-2.el7.noarch.rpm.2289.tmp 的公鑰尚未安裝
2ping-3.2.1-2.el7.noarch.rpm | 62 kB 00:00:01
exiting because "Download Only" specified
查看下載的rpm包
ls /var/cache/yum/x86_64/7
注釋:
yum默認下載到/var/cache/yum/x86_64/7/XXX/packages/ 下面;這里的XXX指的是base,updates,epel等,它跟yum list最右側的字符串一致。
[[root@localhost yum.repos.d]# ls /var/cache/yum/x86_64/7/epel/packages/
2ping-3.2.1-2.el7.noarch.rpm zmap-2.1.1-1.el7.x86_64.rpm
hiredis-0.12.1-1.el7.x86_64.rpm
下載到指定的目錄下
yum install -y 包名 --downloadonly --downloaddir=路徑
[root@localhost yum.repos.d]# yum install -y zmap --downloadonly --downloaddir=/tmp/
已加載插件:fastestmirror
Loading mirror speeds from cached hostfile
* epel: ftp.cuhk.edu.hk
正在解決依賴關系
--> 正在檢查事務
---> 軟件包 zmap.x86_64.0.2.1.1-1.el7 將被 安裝
--> 正在處理依賴關系 libhiredis.so.0.12()(64bit),它被軟件包 zmap-2.1.1-1.el7.x86_64 需要
--> 正在檢查事務
---> 軟件包 hiredis.x86_64.0.0.12.1-1.el7 將被 安裝
--> 解決依賴關系完成
依賴關系解決
================================================================================================
Package 架構 版本 源 大小
================================================================================================
正在安裝:
zmap x86_64 2.1.1-1.el7 epel 124 k
為依賴而安裝:
hiredis x86_64 0.12.1-1.el7 epel 29 k
事務概要
================================================================================================
安裝 1 軟件包 (+1 依賴軟件包)
總下載量:154 k
安裝大小:378 k
Background downloading packages, then exiting:
exiting because "Download Only" specified
[root@localhost yum.repos.d]# ls /tmp
1.txt.bz2
1.txt.gz
1.txt.xz
222
hiredis-0.12.1-1.el7.x86_64.rpm
systemd-private-7d28b5738df345b0bb18e85cef932021-vmtoolsd.service-43orfA
test
yum_save_tx.2017-11-14.23-50.Av9TET.yumtx
yum_save_tx.2017-11-14.23-50.ClMWHy.yumtx
yum_save_tx.2017-11-14.23-56.v0Q9N8.yumtx
zmap-2.1.1-1.el7.x86_64.rpm
如果已經安裝過的包使用—downloadnoly就不起作用了,他會提示這個包已經安裝過了,根本下載不下來
下載已經安裝過過的RPM包
yum reinstall -y 包名 --downloadonly --downloaddir=路徑
[root@localhost yum.repos.d]# yum reinstall -y tree --downloadonly --downloaddir=/tmp/
已加載插件:fastestmirror
Loading mirror speeds from cached hostfile
* epel: ftp.cuhk.edu.hk
正在解決依賴關系
--> 正在檢查事務
---> 軟件包 tree.x86_64.0.1.6.0-10.el7 將被 已重新安裝
--> 解決依賴關系完成
依賴關系解決
================================================================================================
Package 架構 版本 源 大小
================================================================================================
重新安裝:
tree x86_64 1.6.0-10.el7 base 46 k
事務概要
================================================================================================
重新安裝 1 軟件包
總下載量:46 k
安裝大小:87 k
Background downloading packages, then exiting:
tree-1.6.0-10.el7.x86_64.rpm | 46 kB 00:00:00
exiting because "Download Only" specified
[root@localhost yum.repos.d]# ls /tmp/
1.txt.bz2
1.txt.gz
1.txt.xz
222
hiredis-0.12.1-1.el7.x86_64.rpm
systemd-private-7d28b5738df345b0bb18e85cef932021-vmtoolsd.service-43orfA
test
tree-1.6.0-10.el7.x86_64.rpm
源碼包安裝
cd /usr/local/src/
wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.2.32.tar.gz
tar zxvf httpd-2.2.32.tar.gz
cd httpd-2.2.32
./configure --prefix=/usr/local/apache2
make
make install
卸載就是刪除安裝的文件
進入本地
#cd /usr/local/src/
下載源碼包
wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.2.32.tar.gz
[root@localhost yum.repos.d]# cd /usr/local/src/
[root@localhost src]# wget https://mirrors.cnnic.cn/apache/httpd/httpd-2.2.34.tar.gz
--2017-11-15 00:26:41-- https://mirrors.cnnic.cn/apache/httpd/httpd-2.2.34.tar.gz
正在解析主機 mirrors.cnnic.cn (mirrors.cnnic.cn)... 101.6.6.177, 2402:f000:1:416:101:6:6:177
正在連接 mirrors.cnnic.cn (mirrors.cnnic.cn)|101.6.6.177|:443... 已連接。
已發出 HTTP 請求,正在等待回應... 200 OK
長度:7684419 (7.3M) [application/octet-stream]
正在保存至: “httpd-2.2.34.tar.gz”
100%[======================================================>] 7,684,419 1.20MB/s 用時 7.3s
2017-11-15 00:26:49 (1.00 MB/s) - 已保存 “httpd-2.2.34.tar.gz” [7684419/7684419])
[root@localhost src]# ls
httpd-2.2.34.tar.gz
解包
tar zxvf httpd-2.2.32.tar.gz
[root@localhost httpd-2.2.34]# tar -zxvf httpd-2.2.34.tar.gz
[root@localhost src]# ls
httpd-2.2.34 httpd-2.2.34.tar.gz
[root@localhost src]# cd httpd-2.2.34
[root@localhost httpd-2.2.34]# ls
ABOUT_APACHE CHANGES httpd.dsp libhttpd.dep NOTICE server
acinclude.m4 config.layout httpd.mak libhttpd.dsp NWGNUmakefile srclib
Apache.dsw configure httpd.spec libhttpd.mak os support
build configure.in include LICENSE README test
BuildAll.dsp docs INSTALL Makefile.in README.platforms VERSIONING
BuildBin.dsp emacs-style InstallBin.dsp Makefile.win README-win32.txt
buildconf httpd.dep LAYOUT modules ROADMAP
配置相關的選項並生成Makefile
cd httpd-2.2.32
/configure --prefix=/usr/local/apache2
[root@localhost httpd-2.2.34]# cd httpd-2.2.32
[root@localhost src]# /configure --prefix=/usr/local/apache2
checkingfor chosen layout... Apache
checkingfor working mkdir -p... yes
checkingbuild system type... x86_64-unknown-linux-gnu
checkinghost system type... x86_64-unknown-linux-gnu
checkingtarget system type... x86_64-unknown-linux-gnu
ConfiguringApache Portable Runtime library ...
checkingfor APR... reconfig
configuringpackage in srclib/apr now
checkingbuild system type... x86_64-unknown-linux-gnu
checkinghost system type... x86_64-unknown-linux-gnu
checkingtarget system type... x86_64-unknown-linux-gnu
ConfiguringAPR library
Platform: x86_64-unknown-linux-gnu
checkingfor working mkdir -p... yes
APRVersion: 1.5.2
checkingfor chosen layout... apr
checkingfor gcc... no
checkingfor cc... no
checkingfor cl.exe... no
configure: error: in `/usr/local/src/httpd-2.2.34/srclib/apr':
configure: error: no acceptable C compiler found in $PATH
See`config.log' for more details
configurefailed for srclib/apr
進行編譯
[root@localhost httpd-2.2.34]# make
執行完后可以echo $? ,0表示正常
[root@localhost httpd-2.2.34]# echo $?
0
安裝
make install
[root@localhost httpd-2.2.34]# make install
執行完后可以echo $? ,0表示正常
[root@localhost httpd-2.2.34]# echo $?
0
查看apache2目錄
[root@localhost httpd-2.2.34]# ls /usr/local/apache2/
bin build cgi-bin conf error htdocs icons include lib logs man manual modules