Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I was trying to remove write permissions on an entire directory, and I used the incorrect command:

chmod 644 -r sites/default

I meant to type

chmod -R 644 sites/default

The result was this:

chmod: cannot access `644': No such file or directory
$ ls -als sites
total 24
4 drwxr-xr-x  5 user group 4096 Jan 11 10:54 .
4 drwxrwxr-x 14 user group 4096 Jan 11 10:11 ..
4 drwxr-xr-x  4 user group 4096 Jan  5 01:25 all
4 d-w-------  3 user group 4096 Jan 11 10:43 default
4 -rw-r--r--  1 user group 1849 Apr 15  2010 example.sites.php

I fixed the permissions on the default folder with $ chmod 644 sites/default But, the following ls shows a all the files with red backgrounds and question marks. I can't access any files unless I am root.

$ ls -als sites/default
total 0
? ?--------- ? ? ? ?            ? .
? ?--------- ? ? ? ?            ? ..
? ?--------- ? ? ? ?            ? default.settings.php
? ?--------- ? ? ? ?            ? files
? ?--------- ? ? ? ?            ? settings.php

When I log in as root, I can edit all of the files, and their permissions appear correctly. I do not know how to undo the damage caused by using -r with chmod instead of -R.

Any Suggestions?

share|improve this question
    
Try to reproduce this on a folder in your system. I did $ mkdir test $ cd test $ touch test $ cd .. $ chmod 644 -r test And that successfully reproduced my problem. –  alloutfallout Jan 11 '11 at 16:30

2 Answers 2

up vote 2 down vote accepted

First, do this:

chmod 755 sites/default

The output you are seeing is because you don't have execute permission on the directory:

$ mkdir -p foo/bar
$ touch foo/bar/a foo/bar/b foo/bar/c
$ ls -l foo
total 4
drwxr-xr-x 2 thedward thedward 4096 2011-01-11 10:28 bar
$ ls -l foo/bar
total 0
-rw-r--r-- 1 thedward thedward 0 2011-01-11 10:28 a
-rw-r--r-- 1 thedward thedward 0 2011-01-11 10:28 b
-rw-r--r-- 1 thedward thedward 0 2011-01-11 10:28 c
$ chmod 644 foo/bar
$ ls -l foo/bar
total 0
-????????? ? ? ? ?                ? a
-????????? ? ? ? ?                ? b
-????????? ? ? ? ?                ? c
$ chmod 755 foo/bar
$ ls -l foo/bar
total 0
-rw-r--r-- 1 thedward thedward 0 2011-01-11 10:28 a
-rw-r--r-- 1 thedward thedward 0 2011-01-11 10:28 b
-rw-r--r-- 1 thedward thedward 0 2011-01-11 10:28 c
share|improve this answer
    
Thanks that was quite simple, and you answered my question. –  alloutfallout Jan 11 '11 at 16:37

Why not run that same command again with the proper permissions then apply your desired permissions to sites/default?

share|improve this answer
    
I've tried that. When I log in as root, go to the directory default, and run chmod 644 on certain files to give the permissions I want. It appears to work, but when I exit and go back into the normal user, the files still can't be accessed. ls shows ? ?--------- ? ? ? ? –  alloutfallout Jan 11 '11 at 16:27

Your Answer

 
discard

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.