1

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?

1
  • 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. Jan 11, 2011 at 16:30

2 Answers 2

2

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
1
  • Thanks that was quite simple, and you answered my question. Jan 11, 2011 at 16:37
0

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

1
  • 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 ? ?--------- ? ? ? ? Jan 11, 2011 at 16:27

You must log in to answer this question.

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