Tell me more ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am running Ubuntu 12.04 x64 server on ext4 partition.

I set a directory's permission to '766' as below.

sudo chmod 766 /archive

drwxrw-rw-  3 root root  4096 Sep 27 10:50 archive/ <BR><BR><BR>

But, when I tried to create new file through vi editor, permission error has occured.

vi /archive/test.txt
-------- > "/archive/test.txt" [Permission Denied]  

I thought I had "write" permission.

Could anyone help me what is the problem?

share|improve this question
You have created the directory using sudo. That means it belongs to root. If you run "ls -ld archive" you will see the owner as root. I guess you know that. Permission 4 is for read, 2 for write and 1 for execute. To browse (ls) a directory you must have read and execute permission. If you chmod 755 instead of 766 you can browse the dir, because others (you) can read and execute. But again to create a file you need write permission too. I.e if you are not root you need 777 (user=root, group=root, others=you) to write a file. You can make yourself a user of file using chown <yourname> archive – razorxpress Sep 27 '12 at 2:28

migrated from stackoverflow.com Sep 27 '12 at 18:55

2 Answers

Most likely you changed the perms on the directory without changing the perms on test.txt which already existed inside it.

share|improve this answer

A user must have execute permission on a directory to be able to access paths below it (traversal permission). Therefore, you need to add the x permission (chmod 777).

share|improve this answer

Your Answer

 
discard

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