SUDO_EDITOR

SUDO_EDITOR

😄 Written by Zak Zhu

参考

SUDO_EDITOR

man visudo

...

There are two sudoers settings that determine which editor visudo will run.

editor

​ A colon (‘:’) separated list of editors allowed to be used with visudo. visudo will choose the editor that matches the user's SUDO_EDITOR, VISUAL or EDITOR environment variable if possible, or the first editor in the list that exists and is executable. Note that the SUDO_EDITOR, VISUAL and EDITOR environment variables are not preserved by default when the env_reset sudoers option is enabled. The default editor path is /bin/vi which can be set at compile time via the --with-editor configure option.

env_editor

​ If set, visudo will use the value of the SUDO_EDITOR, VISUAL or EDITOR environment variables before falling back on the default editor list. Note that this may create a security hole as it allows the user to run any arbitrary command as root without logging. A safer alternative is to place a colon-separated list of editors in the editor variable. visudo will then only use SUDO_EDITOR, VISUAL or EDITOR if they match a value specified in editor. If the env_reset flag is enabled, the SUDO_EDITOR, VISUAL and/or EDITOR environment variables must be present in the env_keep list for the env_editor flag to function when visudo is invoked via sudo. The default value is on, which can be set at compile time via the --with-env-editor configure option.

...

visudo的默认editor是vi, 下面把editor修改为vim, 这样visudo就支持字体彩色显示

vim /etc/profile.d/SUDO_EDITOR.sh

SUDO_EDITOR="vim"
export SUDO_EDITOR
posted @ 2019-10-09 10:37  ZakZhu  阅读(259)  评论(0编辑  收藏  举报