1. 程式人生 > >yum與apt命令比較,yum安裝出現No package vim available解決辦法

yum與apt命令比較,yum安裝出現No package vim available解決辦法

yum (Yellowdog Updater Modified)是一個集與查詢,安裝,更新和刪除程式的Linux軟體。它執行在RPM包相容的Linux發行版本上,如:RedHat, Fedora, SUSE, CentOS, Mandriva。

今天我在用CentOS 5.5的yum命令安裝的時候出現如下錯誤:

[[email protected] ~]# yum install vim
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.hosting90.cz
* extras: mirror.hosting90.cz
* updates: mirror.hosting90.cz
Setting up Install Process
No package vim available.
Nothing to do

對於此錯誤,我一般習慣性先去更新一下yum倉庫:

#yum -y update

再次執行安裝,發現錯誤依舊,看來這種猜包名的方法不適用;所以接下來可以通過yum的查詢引數來列出vim相關的包名:

[[email protected] yum.repos.d]# yum search vim
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.hosting90.cz
* extras: mirror.hosting90.cz
* updates: mirror.hosting90.cz
===================== Matched: vim ===================
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-minimal.x86_64 : A minimal version of the VIM editor.

通過檢視,我們可以看到,yum列出了詳細的vim相關的包名,這樣就可以順利的安裝vim了:

#yum -y install vim-enhanced.x86_64

以上命令就能執行成功了。當然不僅僅vim安裝,其他程式比如mysql我們也同樣只要先進行yum查詢,再通過匹配詳細包名來進行安裝,就不會出現上述錯誤了

Yum的更新及安裝操作

更新及安裝:
yum install package 安裝指定的安裝包package
yum localinstall package 本地安裝軟體包
yum update 全部更新 
yum update package 更新指定程式包package 
yum check-update 檢查可更新的程式

查詢和顯示
yum info <package> 顯示安裝包資訊 
yum list 顯示所有已經安裝和可以安裝的程式包 
yum list <package> 顯示指定程式包安裝情況 
yum search <keyword>查詢軟體包

Yum和Apt-get對比

Task Red Hat/Fedora Ubuntu/Debian
Adding, Removing and Upgrading Packages
Refresh list of available packages Yum refreshes each time it’s used apt-get update
Install a package from a repository yum installpackage_name apt-get installpackage_name
Install a package file yum installpackage.rpmrpm -ipackage.rpm dpkg –install package.deb
Remove a package rpm -e package_name apt-get removepackage_name
Check for package upgrades yum check-update apt-get -s upgradeapt-get -s dist-upgrade
Upgrade packages yum updaterpm -Uvh [args] apt-get dist-upgrade
Upgrade the entire system yum upgrade apt-get dist-upgrade
Package Information
Get information about an available package yum searchpackage_name apt-cache searchpackage_name
Show available packages yum list available apt-cache dumpavail
List all installed packages yum list installedrpm -qa dpkg –list
Get information about a package yum info package_name apt-cache showpackage_name
Get information about an installed package rpm -qi package_name dpkg –statuspackage_name
List files in an installed package rpm -ql package_name dpkg –listfilespackage_name
List documentation files in an installed package rpm -qd package_name -
List configuration files in an installed package rpm -qc package_name -
Show the packages a given package depends on rpm -qR package_name apt-cache depends
Show other packages that depend on agiven package (reverse dependency) rpm -q -whatrequires [args] apt-cache rdepends
Package File Information
Get information about a package file rpm -qpi package.rpm dpkg –info package.deb
List files in a package file rpm -qpl package.rpm dpkg –contentspackage.deb
List documentation files in a package file rpm -qpd package.rpm -
List configuration files in a package file rpm -qpc package.rpm -
Extract files in a package rpm2cpio package.rpm | cpio -vid dpkg-deb –extractpackage.deb dir-to-extract-to
Find package that installed a file rpm -qf filename dpkg –search filename
Find package that provides a particular file yum provides filename apt-file search filename
Misc. Packaging System Tools
Show stats about the package cache - apt-cache stats
Verify all installed packages rpm -Va debsums
Remove packages from the local cache directory yum clean packages apt-get clean
Remove only obsolete packages from the local cache directory - apt-get autoclean
Remove header files from the local cache directory(forcing a new download of same on next use) yum clean headers apt-file purge
General Packaging System Information
Package file extension .rpm .deb
Repository location configuration /etc/yum.conf

/etc/apt/sources.list