Fixed: [ Error writing: Permission denied ] with Nano

In this article, we cover the reasons that lead to [ Error writing: Permission denied ] with Nano text editor. And, how to fix the issue.

Nano is a text editor, inspired by Pico. At times, we get the above-mentioned error [ Error writing <file-name>: Permission denied ]. For instance, we faced an issue while editing the /etc/hosts file.

For us, the error was: [ Error writing /etc/hosts: Permission denied ]

So, what was the reason that lead to the issue?

It comes up when we are done making changes to the file. And, we want to save the changes made. When we do so, it says we can write the changes to the said file. It mainly shows up when we don’t have the necessary rights to make changes to the file.

Fixed: [ Error writing: Permission denied ] with Nano

Editing files like /etc/hosts requires Administrative rights. And, changes can’t be written to such files when we don’t have the necessary rights.

As regular users, we are given limited access to modify certain system files. If we still go ahead with the changes then, it may break our System. So, such System files can only be edited by a System Administrator.

If you have the necessary rights and understand what you intend to do then use sudo to make changes. We continue with the /etc/hosts example.

As a regular user, we open the file as:

nano /etc/hosts

But, that won’t work as it requires Administrative Rights. So, we can use:

sudo nano /etc/hosts

That should work. Apart from that, we can also use chmod command-line utility to modify file (other than system files) permissions. We reiterate that it is not at all recommended to modify permissions for system files.

We should make changes to the system files only when we understand the implications of doing so.

In conclusion, we have covered here how to fix the writing error we got while using the Nano text editor.

Similar Posts