RE:chmod
> So, the primary question is, is there an easy way to set the permission on
> directories, only directories, and all sub-directories? A related question
> is how to use ls to list only directories.
Use find; eg:
% find /starting/from/here -type d -print
This prints all directories and subdirectories of /starting/from/here,
including /starting/from/here.
To actually do something, write a little script and/or use the exec
flag:
% cat > something
#!/bin/bash
chmod 755 $1
<CTRL>-d
% chmod 755 something
% find /start/here/now -type d -exec ./something {} \;
equivalently:
% find /start/here/now -type d -exec chmod 755 {} \;
See the man page for find for details.
> And if anyone's in a 'splaining mood, here's another one: how do
> you set all files so that the group permissions match the user
> permissions? (If you have three files who's permissions are, for
> example, 700, 600, 500, and you want them to be 770, 660, 550
> respectively.)
Look at the info page for chmod:
% info chmod
You actually want to go to File permissions->Symbolic Models->Copying
Permissions, which has the following:
Copying Existing Permissions
----------------------------
You can base a file's permissions on its existing permissions. To
do this, instead of using `r', `w', or `x' after the operator, you use
the letter `u', `g', or `o'. For example, the mode
o+g
adds the permissions for users who are in a file's group to the
permissions that other users have for the file. Thus, if the file
started out as mode 664 (`rw-rw-r--'), the above mode would change it
to mode 666 (`rw-rw-rw-'). If the file had started out as mode 741
(`rwxr----x'), the above mode would change it to mode 745
(`rwxr--r-x'). The `-' and `=' operations work analogously.
Although I should note that this doesn't work for me when setting
other permissions, just group permissions--I can't get it to set write
permissions for other. Fortunately, it seems to work for what you
want to do.
Andrew.
--
To UNSUBSCRIBE, email to debian-user-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Reply to:
- References:
- chmod
- From: Daniel D Jones <ddjones@riddlemaster.org>(by way of Daniel D Jones <ddjones@riddlemaster.org>)