CentOS上-bash: vim: command not found问题解决

CentOS上-bash: vim: command not found问题解决

问题现象

-bash: vim: command not found

在CentOS上使用vim操作文件的时候,可能会遇到-bash: vim: command not found的情况,如:

[root@dev05 redis-3.2.3]# vim redis.conf -bash: vim: command not found

问题原因

出现该问题,主要是因为默认安装的是vi,vim命令并没有安装完全,如使用rpm -qa|grep vim来看一下:

[root@dev05 redis-3.2.3]#  rpm -qa|grep vimvim-minimal-7.4.629-5.el6.x86_64[root@dev05 redis-3.2.3]#

从上述的结果,我们可以看到,目前CentOS上只装了vim的最小化安装:

vim-minimal-7.4.629-5.el6.x86_64

解决方法

解决如上问题的方法,可以采取安装全vim即可,如使用yum -y install vim*命令:

[root@dev05 redis-3.2.3]# yum -y install vim*Loaded plugins: fastestmirrorSetting up Install ProcessLoading mirror speeds from cached hostfilePackage 2:vim-minimal-7.4.629-5.el6.x86_64 already installed and latest versionResolving Dependencies--> Running transaction check---> Package vim-X11.x86_64 2:7.4.629-5.el6 will be installed--> Processing Dependency: gtk2 >= 2.6 for package: 2:vim-X11-7.4.629-5.el6.x86_64--> Processing Dependency: perl(:MODULE_COMPAT_5.10.1) for package: 2:vim-X11-7.4.629-5.el6.x86_64--> Processing Dependency: hicolor-icon-theme for package: 2:vim-X11-7.4.629-5.el6.x86_64--> Processing Dependency: libperl.so()(64bit) for package: 2:vim-X11-7.4.629-5.el6.x86_64--> Processing Dependency: libpango-1.0.so.0()(64bit) for package: 2:vim-X11-7.4.629-5.el6.x86_64--> Processing Dependency: libgtk-x11-2.0.so.0()(64bit) for package: 2:vim-X11-7.4.629-5.el6.x86_64--> Processing Dependency: libgpm.so.2()(64bit) for package: 2:vim-X11-7.4.629-5.el6.x86_64--> Processing Dependency: libgdk_pixbuf-2.0.so.0()(64bit) for package: 2:vim-X11-7.4.629-5.el6.x86_64--> Processing Dependency: libgdk-x11-2.0.so.0()(64bit) for package: 2:vim-X11-7.4.629-5.el6.x86_64--> Processing Dependency: libXt.so.6()(64bit) for package: 2:vim-X11-7.4.629-5.el6.x86_64--> Processing Dependency: libX11.so.6()(64bit) for package: 2:vim-X11-7.4.629-5.el6.x86_64--> Processing Dependency: libSM.so.6()(64bit) for package: 2:vim-X11-7.4.629-5.el6.x86_64--> Processing Dependency: libICE.so.6()(64bit) for package: 2:vim-X11-7.4.629-5.el6.x86_64---> Package vim-common.x86_64 2:7.4.629-5.el6 will be installed---> Package vim-enhanced.x86_64 2:7.4.629-5.el6 will be installed---> Package vim-filesystem.x86_64 2:7.4.629-5.el6 will be installed--> Running transaction check---> Package gdk-pixbuf2.x86_64 0:2.24.1-5.el6 will be installed--> Processing Dependency: libpng12.so.0(PNG12_0)(64bit) for package: gdk-pixbuf2-2.24.1-5.el6.x86_64--> Processing Dependency: libjpeg.so.62(LIBJPEG_6.2)(64bit) for package: gdk-pixbuf2-2.24.1-5.el6.x86_64--> Processing Dependency: libtiff.so.3()(64bit) for package: gdk-pixbuf2-2.24.1-5.el6.x86_64--> Processing Dependency: libpng12.so.0()(64bit) for package: gdk-pixbuf2-2.24.1-5.el6.x86_64--> Processing Dependency: libjpeg.so.62()(64bit) for package: gdk-pixbuf2-2.24.1-5.el6.x86_64--> Processing Dependency: libjasper.so.1()(64bit) for package: gdk-pixbuf2-2.24.1-5.el6.x86_64---> Package gpm-libs.x86_64 0:1.20.6-12.el6 will be installed---> Package gtk2.x86_64 0:2.24.23-6.el6 will be installed... ...Installed:  vim-X11.x86_64 2:7.4.629-5.el6                                 vim-common.x86_64 2:7.4.629-5.el6                                 vim-enhanced.x86_64 2:7.4.629-5.el6                                 vim-filesystem.x86_64 2:7.4.629-5.el6                                Dependency Installed:  atk.x86_64 0:1.30.0-1.el6                    avahi-libs.x86_64 0:0.6.25-15.el6           cairo.x86_64 0:1.8.8-6.el6_6            cups-libs.x86_64 1:1.4.2-72.el6          fontconfig.x86_64 0:2.8.0-5.el6                freetype.x86_64 0:2.3.11-15.el6_6.1                gdk-pixbuf2.x86_64 0:2.24.1-5.el6            gnutls.x86_64 0:2.8.5-18.el6                gpm-libs.x86_64 0:1.20.6-12.el6         gtk2.x86_64 0:2.24.23-6.el6              hicolor-icon-theme.noarch 0:0.11-1.1.el6       jasper-libs.x86_64 0:1.900.1-16.el6_6.3            libICE.x86_64 0:1.0.6-1.el6                  libSM.x86_64 0:1.2.1-2.el6                  libX11.x86_64 0:1.6.0-6.el6             libX11-common.noarch 0:1.6.0-6.el6       libXau.x86_64 0:1.0.6-4.el6                    libXcomposite.x86_64 0:0.4.3-4.el6                 libXcursor.x86_64 0:1.1.14-2.1.el6           libXdamage.x86_64 0:1.1.3-4.el6             libXext.x86_64 0:1.3.2-2.1.el6          libXfixes.x86_64 0:5.0.1-2.1.el6         libXft.x86_64 0:2.3.1-2.el6                    libXi.x86_64 0:1.7.2-2.2.el6                       libXinerama.x86_64 0:1.1.3-2.1.el6           libXrandr.x86_64 0:1.4.1-2.1.el6            libXrender.x86_64 0:0.9.8-2.1.el6       libXt.x86_64 0:1.1.4-6.1.el6             libjpeg-turbo.x86_64 0:1.2.1-3.el6_5           libpng.x86_64 2:1.2.49-1.el6_2                     libthai.x86_64 0:0.1.12-3.el6                libtiff.x86_64 0:3.9.4-10.el6_5             libxcb.x86_64 0:1.9.1-3.el6             pango.x86_64 0:1.28.1-10.el6             perl.x86_64 4:5.10.1-141.el6                   perl-Module-Pluggable.x86_64 1:3.90-141.el6        perl-Pod-Escapes.x86_64 1:1.04-141.el6       perl-Pod-Simple.x86_64 1:3.13-141.el6       perl-libs.x86_64 4:5.10.1-141.el6       perl-version.x86_64 3:0.77-141.el6       pixman.x86_64 0:0.32.4-4.el6                  Complete!

安装完毕之后,我们来验证一下vim是否可以使用了,使用vim redis.conf 打开文件成功。

至此,问题解决

推荐阅读