Ubuntu – ‘[Error writing /filename: Permission denied]’ while trying to save a file using the nano editor

nanopermissions

Using the Nano text editor, I'm trying to save and exit a file.
I already have the file named.

I click Ctrl+X to exit. And then I click Y because I want to save the file. It asks for file to write, I pressed Enter to use the default name because its already named.

The problem is I get this message.

[Error writing /filename: Permission denied]

What am I doing wrong?

Best Answer

Well, you don't have the rights to write that file. Use

sudo nano [filename]