0

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/example.org/public$ touch index.html
thomas@vannevar:~/public/example.org/public$ ls
index.html
thomas@vannevar:~/public/example.org/public$ nano index.html

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

Press Enter to continue starting nano.

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

THIS WORKS

http://pricklytech.wordpress.com/2010/12/12/ubuntu-nano-error-reading-home-nano_history-permission-denied/

3
  • 3
    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: en.wikipedia.org/wiki/Filesystem_permissions#Octal_notation
    – cjc
    May 17, 2012 at 18:13
  • 1
    The permission denied is for /home/thomas/.nano_history because its having trouble reading it. What does ls -l /home/thomas/.nano_history say? May 17, 2012 at 18:15
  • -rw------- 1 root root 111 May 17 14:13 /home/thomas/.nano_history May 17, 2012 at 18:18

3 Answers 3

7

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

thomas@vannevar:~/public/example.org/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.

5

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.

0

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--)

5
  • :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, 2012 at 18:28
  • 2
    The leading dash turns into a 'd' for directories.
    – gparent
    May 17, 2012 at 18:33
  • ahhh, i see. d for directory, - for file, p for named pipe... wikipedia, i love you
    – acolyte
    May 17, 2012 at 18:37
  • getting octal to show up in ls linuxforums.org/forum/newbie/… May 17, 2012 at 18:38
  • huh. looks like you found the answer on your own. the google-fu is somewhat strong (if slow to appear) in this one. also, i prefer to just calc it in my head. it's only 3 bits after all.
    – acolyte
    May 17, 2012 at 18:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .