Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an ubuntu server. I created a simple index.html file using touch. and tried to use nano and it turns out the permission is denied. Why is this? If I just made the file on the server why wouldn't I have write access in the first place? My second question is if I wanted to change the permissions to the number format 644 (is that what a html file on the server should be set to?) how do I view what it currently is how do I convert -rw-rw-r-- to the numeral format? I want to view -ls -l with the numeral permissions format rather then -rw-rw-r--. The index.html file is running on the server alright.

thomas@vannevar:~/public/$ touch index.html
thomas@vannevar:~/public/$ ls
thomas@vannevar:~/public/$ nano index.html

Error reading /home/thomas/.nano_history: Permission denied

Press Enter to continue starting nano.

thomas@vannevar:~/public/$ ls -l
total 0
-rw-rw-r-- 1 thomas thomas 0 May 17 13:57 index.html


share|improve this question
The error pertains to the file /home/thomas/.nano_history, not to index.html. Check the permissions for that file, and the parent directory of that file (i.e., ls -l /home/thomas/.nano_history and ls -ld /home/thomas/). Also, for octal permission notation: – cjc May 17 '12 at 18:13
The permission denied is for /home/thomas/.nano_history because its having trouble reading it. What does ls -l /home/thomas/.nano_history say? – becomingwisest May 17 '12 at 18:15
-rw------- 1 root root 111 May 17 14:13 /home/thomas/.nano_history – ThomasReggi May 17 '12 at 18:18
up vote 7 down vote accepted

Your problem is reading nano's history file (.nano_history), as indicated very clearly in this massively whitespaced error line:

thomas@vannevar:~/public/$ nano index.html

Error reading /home/thomas/.nano_history: Permission denied

Press Enter to continue starting nano.

This is opened prior to nano opening your file (which works fine because 644 is okay for this)

Looks like your home folder/.nano_history's permissions might be set too tight.

Following your comment:

-rw------- 1 root root 111 May 17 14:13 /home/thomas/.nano_history

As you can see only root's user has read and write permissions, no one else.

You want to do sudo chown thomas:thomas ~/.nano_history to fix this issue.

share|improve this answer

Given what you have shown, your problem is almost certainly related to your use of sudo nano at some point in the past to edit a file. Nano created a history file in the home directory, but with root permissions.

Use sudo rm /home/thomas/.nano_history or sudo chown thomas:thomas /home/thomas/.nano_history to fix the permissions on that file.

Many programs you run with sudo may have a side-effect of creating root-owned files in your home directory if you are not careful. If you know this is going to happen with a particular program like nano, you may be better off using sudo -i to start a new shell with a root environment, and then running your commands.

share|improve this answer

permissions are fairly simple to understand. there are 3 places in each 'group' for permissions. read, write, execute. so, you can think of it as 3 sets of 3 bits.

as an example, the permission set -rw-rw-r-- equates to -110110100. you can break those up into groups of 3 bits (so rw-, rw-, and r-- => 110, 110, 100). Convert those groups of 3 bits into octal ( since 2^3 == 8 ) and boom! you got your number code.

for given example: 110= 6 110= 6 100= 4

shortcut way: the 'execute' bit (x) adds 1 to the octal value, the 'write' bit (w) adds 2, and the 'read' bit (r) adds 4.

(644 would be -rw-r--r--)

share|improve this answer
Thank for the explication! – ThomasReggi May 17 '12 at 18:26
:tips hat: i'm not sure that the leading dash does (the dash before the first 'rw-' group) so i'm not sure how it factors into the numeric representation. sorry. – acolyte May 17 '12 at 18:28
The leading dash turns into a 'd' for directories. – gparent May 17 '12 at 18:33
ahhh, i see. d for directory, - for file, p for named pipe... wikipedia, i love you – acolyte May 17 '12 at 18:37
getting octal to show up in ls… – ThomasReggi May 17 '12 at 18:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.