为什么RHEL默认安装了两个vim?

为什么RHEL默认安装了两个vim?

我使用的是 RHEL 8.3 系统。我发现内置的vimvi都是vim.它们具有相同的版本,但编译方式不同。以下是我的测试:

[root@192 ~]# which vim
/usr/bin/vim
[root@192 ~]# which vi
/usr/bin/vi
[root@192 ~]# ls -lah `which vim`
-rwxr-xr-x. 1 root root 3.0M Jun  3  2020 /usr/bin/vim
[root@192 ~]# ls -lah `which vi`
-rwxr-xr-x. 1 root root 1.2M Jun  3  2020 /usr/bin/vi
[root@192 ~]# vim --version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jun  3 2020 09:07:54)
Included patches: 1-1763
Modified by <[email protected]>
Compiled by <[email protected]>
Huge version without GUI.  Features included (+) or not (-):
+acl               +farsi             +mouse_sgr         -tag_any_white
+arabic            +file_in_path      -mouse_sysmouse    -tcl
+autocmd           +find_in_path      +mouse_urxvt       +termguicolors
-autoservername    +float             +mouse_xterm       +terminal
-balloon_eval      +folding           +multi_byte        +terminfo
+balloon_eval_term -footer            +multi_lang        +termresponse
-browse            +fork()            -mzscheme          +textobjects
++builtin_terms    +gettext           +netbeans_intg     +timers
+byte_offset       -hangul_input      +num64             +title
+channel           +iconv             +packages          -toolbar
+cindent           +insert_expand     +path_extra        +user_commands
-clientserver      +job               +perl/dyn          +vertsplit
-clipboard         +jumplist          +persistent_undo   +virtualedit
+cmdline_compl     +keymap            +postscript        +visual
+cmdline_hist      +lambda            +printer           +visualextra
+cmdline_info      +langmap           +profile           +viminfo
+comments          +libcall           +python/dyn        +vreplace
+conceal           +linebreak         +python3/dyn       +wildignore
+cryptv            +lispindent        +quickfix          +wildmenu
+cscope            +listcmds          +reltime           +windows
+cursorbind        +localmap          +rightleft         +writebackup
+cursorshape       +lua/dyn           +ruby/dyn          -X11
+dialog_con        +menu              +scrollbind        -xfontset
+diff              +mksession         +signs             -xim
+digraphs          +modify_fname      +smartindent       -xpm
-dnd               +mouse             +startuptime       -xsmp
-ebcdic            -mouseshape        +statusline        -xterm_clipboard
+emacs_tags        +mouse_dec         -sun_workshop      -xterm_save
+eval              +mouse_gpm         +syntax            
+ex_extra          -mouse_jsbterm     +tag_binary        
+extra_search      +mouse_netterm     +tag_old_static    
   system vimrc file: "/etc/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/etc"
 f-b for $VIMRUNTIME: "/usr/share/vim/vim80"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/python3.6m -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       
Linking: gcc   -L. -Wl,-z,relro  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--enable-new-dtags -Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld  -Wl,-z,relro  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -L/usr/local/lib -Wl,--as-needed -o vim        -lm  -lselinux   -lncurses -lacl -lattr -lgpm -ldl   -Wl,--enable-new-dtags -Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -fstack-protector-strong -L/usr/local/lib  -L/usr/lib64/perl5/CORE -lperl -lpthread -lresolv -ldl -lm -lcrypt -lutil -lc        
[root@192 ~]# vi --version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jun  3 2020 09:07:06)
Included patches: 1-1763
Modified by <[email protected]>
Compiled by <[email protected]>
Small version without GUI.  Features included (+) or not (-):
+acl               -extra_search      -mouse_netterm     -tag_old_static
-arabic            -farsi             -mouse_sgr         -tag_any_white
+autocmd           -file_in_path      -mouse_sysmouse    -tcl
-autoservername    -find_in_path      -mouse_urxvt       -termguicolors
-balloon_eval      -float             -mouse_xterm       -terminal
-balloon_eval_term -folding           +multi_byte        +terminfo
-browse            -footer            -multi_lang        -termresponse
+builtin_terms     +fork()            -mzscheme          -textobjects
-byte_offset       -gettext           -netbeans_intg     -timers
-channel           -hangul_input      -num64             -title
-cindent           +iconv             +packages          -toolbar
-clientserver      -insert_expand     -path_extra        -user_commands
-clipboard         -job               -perl              +vertsplit
-cmdline_compl     +jumplist          -persistent_undo   -virtualedit
+cmdline_hist      -keymap            -printer           +visual
-cmdline_info      -lambda            -profile           -visualextra
-comments          -langmap           -python            -viminfo
-conceal           -libcall           -python3           -vreplace
-cryptv            -linebreak         -quickfix          +wildignore
-cscope            -lispindent        -reltime           -wildmenu
+cursorbind        +listcmds          -rightleft         +windows
-cursorshape       -localmap          -ruby              +writebackup
-dialog            -lua               +scrollbind        -X11
-diff              -menu              -signs             -xfontset
-digraphs          -mksession         -smartindent       -xim
-dnd               -modify_fname      -startuptime       -xpm
-ebcdic            -mouse             -statusline        -xsmp
-emacs_tags        -mouse_dec         -sun_workshop      -xterm_clipboard
-eval              -mouse_gpm         -syntax            -xterm_save
+ex_extra          -mouse_jsbterm     +tag_binary        
   system vimrc file: "/etc/virc"
     user vimrc file: "$HOME/.virc"
 2nd user vimrc file: "~/.vim/virc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/etc"
 f-b for $VIMRUNTIME: "/usr/share/vim/vim80"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/python3.6m -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       
Linking: gcc   -Wl,-z,relro  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -L/usr/local/lib -Wl,--as-needed -o vim        -lm  -lselinux -lncurses -lacl -lattr -ldl           
[root@192 ~]#

为什么他们维护两个不同的版本?对我来说有点奇怪。如果他们希望vi用户拥有一个现代编辑器,他们可以简单地符号链接到vim.出于好奇,下面是 Ubuntu 20.04 系统上的结果。vi和都vim指向nvim,这是合理的。

root@u2004:~# which vi
/usr/bin/vi
root@u2004:~# which vim
/usr/bin/vim
root@u2004:~# ls -la `which vi`
lrwxrwxrwx 1 root root 20 Aug 28  2020 /usr/bin/vi -> /etc/alternatives/vi
root@u2004:~# ls -la `which vim`
lrwxrwxrwx 1 root root 21 Apr  1 08:28 /usr/bin/vim -> /etc/alternatives/vim
root@u2004:~# ls -la /etc/alternatives/vi
lrwxrwxrwx 1 root root 13 Apr  1 08:28 /etc/alternatives/vi -> /usr/bin/nvim
root@u2004:~# ls -la /etc/alternatives/vim
lrwxrwxrwx 1 root root 13 Apr  1 08:28 /etc/alternatives/vim -> /usr/bin/nvim
root@u2004:~# man hier
root@u2004:~# readlink -f `which vi`
/usr/bin/nvim
root@u2004:~# readlink -f `which vim`
/usr/bin/nvim
root@u2004:~#

答案1

vi以与经典 最大程度兼容的模式启动 Vim(极简版本)vi,打包为vim-minimal.另一方面,vim启动一个功能更丰富的版本,具有更现代的默认设置,打包为vim-enhanced.

旧版本的RHEL以前没有这个/etc/alternatives系统,所以他们以前就是这样做的,所以RHEL为了向后兼容仍然这样做。

相关内容