amazonlinux / amazon-linux-2023

Amazon Linux 2023
https://aws.amazon.com/linux/amazon-linux-2023/
Other
500 stars 38 forks source link

[Bug] - visudo starts wrong editor #640

Open g24swint opened 4 months ago

g24swint commented 4 months ago

Describe the bug vIsudo is bringing up the wrong editor and starting nano instead of vim. This is without having installed nano but just using the default as shipped with AL2023

To Reproduce Steps to reproduce the behavior:

  1. Login into AL2023 instance
  2. run sudo visudo

Expected behavior The editor that starts should be vim and not nano. update-alternatives does not provide any alternatives even though it should offer a vim, ed, and (lastly) nano offering

daniejstriata commented 4 months ago

@g24swint I install vim-enhanced package first: dnf install vim then add:

export VISUAL=vim
export EDITOR=vim

to your .bashrc and reload with source .bashrc From there on you'll see vim being used and not nano. This is for vipw and vigr too.

elsaco commented 4 months ago

From visudo man page: The default editor path is /usr/bin/nano:/usr/bin/vim:/usr/bin/vi

Because nano is part of the AL2023 base image and vim is not nano will be used by visudo. Set your preferred editor just like @daniejstriata mentioned above.