18

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?

Kulfy
  • 18,154
Renee
  • 189

6 Answers6

33

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

sudo nano [filename]
kiri
  • 28,986
HCBT
  • 341
5

If you're the admin, open another terminal

sudo chmod 777 <filename>
<password>

go back to your "nano" terminal save the file. Change permissions back on the filename if you care, they wee most likely 755

1

I got your problem and to resolve this error there is an easy way. Basically, you need to do nothing but switch from normal user to root user and for that type the command:

sudo su

and then hit Enter. su means "switch user".

Now you have full access, so do whatever you want to do because now you have super user's power.

To create a file in the nano text editor simply type:

nano [file name]

then hit Enter. Now you can use all features of nano without any interruption.

Vishal
  • 11
0

I had the same problem. Solved it in the following way:

  1. Go to Search, and type bash.
  2. Right-click on bash and run as administrator.

Now it should work normally.

Error404
  • 8,278
  • 3
  • 35
  • 60
0

If using Git Bash on Windows, it helps to run the application as an Administrator.

0

Most of what has been said works. However, there is an extreme situation. It goes like this:

sudo nano filename

"Username is not in the sudoers file."

What happens if the user doesn't have this privilege? In that case, you can try the following: Open Linux in "Recovery Mode". Then select "root drop to root shell prompt". After entering the root password, type "adduser username sudo"."