2

Question is;

I just setup AWS EC2 micro instance = Ubuntu 11.04 32bit - (ami-e9d81980) All is running well. Added new user successfully and now want to give root access to new-user. So I did;

$ sudo visudo
new-user    ALL=(ALL) ALL

Problem is when I ESC:wq I get [ Unknown Command ] - Scratching my head. Any help would be appreciated. Thank you.

mrmoe
  • 21
  • 2
  • 3
    If you type `:help` to what you think is `vi`, do you get the usual `vim` help page? Or do you get some other pile of nonsense? I wonder if some horrible editor like `nano` or worse is being used in place of `vim`. Check `ls -l /usr/bin/editor /etc/alternatives/editor` to see what program is likely spawned by `visudo`. – sarnold Jan 16 '12 at 03:53
  • +1: That `[ Unknown Command ]` sounds exactly like `nano`. Try `Ctrl-X` to exit and save your changes. – fission Jan 16 '12 at 03:58
  • Just wanted to add that `sudo visudo` is a dangerous pattern because if you change the sudoers file such that you no longer have permission to run `sudo visudo` you can lock yourself out of your own system. Use `sudo -s` or `sudo bash` first and then run `visudo` as the root user. Test your changes before logging out of the root user. – Ladadadada Feb 29 '12 at 10:27

2 Answers2

2

Your best bet in Ubuntu is to switch your editor in alternatives:

sudo update-alternatives --config editor

and select one of the vim options.

Andrew
  • 8,002
  • 3
  • 36
  • 44
1

This is sounds like you have no vim editor as default in your machine, inorder to use the vim as editor.

Execute below command, to make vim as editor

# export EDITOR=vim

And now try to edit the file visudo /etc/sudoers (Ubuntu) and save by executing the vim commands ESC !wq

Mughil
  • 1,929
  • 1
  • 19
  • 28