[Fix Error] visudo: no editor found (editor path = /usr/bin/vi)

by Jack
5 minutes
[Fix Error] visudo: no editor found (editor path = /usr/bin/vi)

For some reason, if you see the following error on Ubuntu, Arch Linux or Debian, then here's the easy fix for it.

[jer@jer~]$ sudo visudo
visudo: no editor found (editor path = /usr/bin/vi)

Why this error arises?

There are two reasons for it.

  1. The sudo package is not installed or is corrupted.
  2. Vi is not installed or you removed it already.

What exactly is visudo?

Visudo is a Linux CLI utility used to edit the sudoers file safely. The sudoers file is a configuration file that controls who can run commands on the Linux system with sudo privileges.

Here are some of the reasons why you should use visudo:

  • To prevent multiple users from editing the sudoers file at the same time.
  • To check the syntax of the sudoers file before saving it.
  • For receiving warnings about potential security risks when making changes to the sudoers file.

How to fix this error?

  1. Reinstall sudo package: As root user run, apt install sudo on Ubuntu and Debian. And run pacman -S sudo on Arch Linux.
  2. If you have nano instead of Vim or Vi then run visudo like this as root user: EDITOR=nano visudo

In case you don't have nano either, then you can install it first and then try running the visudo.

Installing nano: pacman -S nano on Arch Linux, apt install nano on Ubuntu and Debian.

Installing Vi: pacman -S vi on Arch Linux, apt install vi on Ubuntu and Debian.

Conclusion:

visudo is an important utility on Linux operating system to change the behavior of the system users. I usually use it to remove sudo password and I once got into this error and I had to look for solution. I found the solution so I thought I must share it with others.