.nano_history permissions error

This is possible if .nano_history does not exist and you edit any file as root. Start a search action with Ctrl+W and .nano_history has the wrong ownership.

sudo chown arthur-dent:arthur-dent /home/arthur-dent/.nano_history

Later, the ownership of the file will not be changed.

I've tested:

% ls -l .nano_history
ls: cannot access .nano_history: No such file or directory

% sudo nano ~/tmp/<any_file>

Ctrl+W

Search anything.

Ctrl+X

% ls -l .nano_history
-rw------- 1 root root 6 Mai  3 22:08 .nano_history

% sudo chown aboettger:aboettger .nano_history
% ls -l .nano_history                    
-rw------- 1 aboettger aboettger 6 Mai  3 22:08 .nano_history

% sudo nano ~/tmp/<any_file>

Ctrl+W

Search anything.

Ctrl+X

% ls -l .nano_history  
-rw------- 1 aboettger aboettger 11 Mai  3 22:11 .nano_history

This can happen when you don't own the .nano_history file that's normally contained inside your home directory. This happened to me when I ran nano for the first time on my Ubuntu install along with sudo. This meant that .nano_history was owned by root and not readable unless sudo was used with nano each time. When it wasn't used, nano complained on startup with 'Permission denied'. Copy and paste this exactly into your terminal to fix the issue:

sudo chown $USER:$(id -gn) $HOME/.nano_history