Rhel
為什麼RHEL預設安裝了兩個vim?
我在 RHEL 8.3 系統上。我發現內置的
vim
和vi
都是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 <bugzilla@redhat.com> Compiled by <bugzilla@redhat.com> 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 <bugzilla@redhat.com> Compiled by <bugzilla@redhat.com> 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:~#
vi
以與經典的 最大兼容的模式啟動(極簡版本)Vimvi
,打包為vim-minimal
. 另一方面,vim
使用更現代的預設設置啟動功能更豐富的版本,打包為vim-enhanced
.舊版本的 RHEL 過去沒有
/etc/alternatives
系統,所以這是他們過去的做法,所以 RHEL 仍然這樣做是為了向後兼容。