Securely edit configuration files as specific user.
Ensure that you have the SUDO_EDITOR
, VISUAL
or at least EDITOR
environment variable defined to a preferred text editor.
[...] # Define default editor and pager export EDITOR="/usr/bin/vim" export SUDO_EDITOR="$EDITOR" [...]
Edit specific file as root
.
$ sudoedit /etc/hosts
Edit specific file as zookeeper
.
$ sudoedit -u zookeeper zookeeper/conf/zoo.cfg
This is way better than using sudo
command as it clearly exposes your system.
$ sudo -u zookeeper vim zookeeper/conf/zoo.cfg
Simple as that.