# Help: Directories missing after chmod -R



## bomix (Apr 6, 2009)

Hi all.
Newbie alert! 

How do I recover from a 'chmod -R' ?

I'm building a fileserver using ZFS and I "accidentaly" did a 'chmod -R' (as root) in my "tank" directory. I was completely sure that -R meant recursive. Apparantly -R means something else...

Anyway, it looks like the files are still there:


```
[root@fsrv /]# zpool list
NAME                    SIZE    USED   AVAIL    CAP  HEALTH     ALTROOT
tank                   1.81T   1.10T    728G    60%  ONLINE     -

[root@fsrv /]# zfs list
NAME             USED  AVAIL  REFER  MOUNTPOINT
tank             564G   349G    21K  /tank
tank/documents    18K   349G    18K  /tank/documents
tank/media       564G   349G   564G  /tank/media

[root@fsrv /] ll /tank
total 0
```

I hope there's some way to recover the files? I'd rather like to _not_ have to transfer the 500+ GB again 

/Bomix


----------



## bomix (Apr 7, 2009)

Oh, joy! Problem solved!

It turns out that:


my problem was actually a ZFS mount problem. I had reinstalled the server and brought an "old" zpool over. I had _zpool import_'ed it, but I hadn't mounted the zfs filesystems on it. A simple 
	
	



```
zfs mount -a
```
 did the trick. All files are back. Phew! 
'chmod -R ' really _is_ recursive. I just did not understand the man-page about the -R option. Actually, it is still not absolutely 100% clear to me what the man-page is saying about -R, even after reading it at least 10 times.

/bomix


----------



## fronclynne (Apr 7, 2009)

*Something about Muad'dib*

You mean

```
-R      Change the modes of the file hierarchies rooted in the files
             instead of just the files themselves.
```
?

I think the man page is assuming you keep the notion that a directory is just a type of file in the fore at all times, and a directory tree is just another name for a file hierarchy rooted in a file, right?

Maybe someone else can explain it better, but I must admit that it makes sense to me as written.


----------



## phoenix (Apr 7, 2009)

I always found it easier to understand Unix permissions by looking at directories as files, where the contents of the "file" (directory) were the names of the files inside the "file" (directory).

Hence, *read* permissions let you open the directory and view the contents (ls on a directory is the same as cat on a file), *write* let you edit the contents of the directory (rm a file is the same as removing a line from the directory), and *execute* let you "run" the directory meaning you could change the current directory to the contents of the directory (cd).

Thus, the man page makes perfect sense.


----------

