This answer will do what you need, although usually you do not add specific usernames to sudoers . Instead, you have a sudoers group and just add your user to this group when necessary. Thus, you do not need to use visudo more than once when granting users sudo permission.
If you are on Ubuntu, the group is most likely already configured and is called admin :
$ sudo cat /etc/sudoers
...
In other distributions, such as Arch and some others, it is usually called wheel , and you may need to configure it: Arch Wiki
To give full privileges to users of the wheelset group when they precede the command with "sudo", uncomment the following line:% wheel ALL = (ALL) ALL
Also note that on most systems, visudo will read the EDITOR environment EDITOR or use vi by default. Therefore, you can try EDITOR=vim visudo use vim as an editor.
To add a user to a group, you must run (with root privileges):
where groupname is your group (say admin or wheel ), and username is the username (say john ).
Lev Levitsky Jun 19 2018-12-12T00: 00Z
source share