In this tutorial, you will learn how to fix the error "visudo: no editor found" on Linux.
Visudo is a very useful and important command when it comes to making changes in the sudoers
/etc/sudoers file, as it doesn't only opens the sudoers file safely, but it also checks that the syntax that is being used in the sudoers file is correct, which means if the syntax in the sudoers file is not correct, then it lets you know that the file can't be saved because of syntax errors.
What visudo does, is that it opens the sudoers
/etc/sudoers file using the default text editor.
Now this is also the reason why this error happen, when you run visudo, the system will try to use the default text editor to open the sudoers file, when the default text editor is not set, or not configured correctly, then you will encounter the error "visudo: no editor found"
How to fix this error?
The error "visudo: no editor found" can be easily fixed by following the steps below.
Fix "visudo: no editor found"
Step 1 - Install nano text editor
Before setting nano as the default text editor, you need to make sure that you have nano installed on your Arch Linux Machine.
Installing nano is quite simple, and it cane be done easily from the terminal, as nano package is available in the AUR repository on Arch Linux.
To install nano, simply run the command below.
sudo pacman -S nano
Step 2 - Login as root
Once nano editor is installed on your system, now you need to launch your terminal, by pressing CTRL + ALT +T, and login as root in your system.
To do so, simply run the command below.
You will be asked to enter root password, simply enter root password and press enter to login as root.
And you will be logged in as root.
Step 3 - Set nano as default text editor
We are setting nano as the default text editor for visudo. So when we execute the
visudo command, the sudoers file will be opened via nano.
Setting nano as the default text editor in Arch Linux, and any other Linux distro, can be done by issuing the following command.
To make this change permanent, so that you can run
visudo after rebooting your machine, you need to define the default text editor in the sudoers file
1) First open the sudoers file using nano text editor.
2) Next add the below into the sudoers file.
3) Once you define the default text editor, the sudoers file should look like this.
4) Once done, make sure to save changes in the sudoers file, by pressing the CTRL + X key, then enter.
Step 4 - Use Visudo command
nano is set now as the default text editor, all you need to do now is run the
visudo command, to verify that the error "visudo: no editor found" is fixed.
And it should open the sudoers file using nano text editor, as shown in the screenshot below. This means that the error "visudo: no editor found" is now fixed, and you can proceed to use
visudo command on your system.
In this tutorial, you learned how to fix the error "visudo: no editor found". By now you should be able to use visudo command to manage the sudoers file in your system.