Oh dear!

 :    I inadvertently changed permissions on all directories and 
 : files in my ~/ to 755 (including the dot files, of course). Only 
 : the directories should have those perms; regular files should be 
 : 644.

Especially if you are on a multiuser machine, I would suggest doing 
something like this right away:

  cd ~ && chmod 0700 -- .gnupg .ssh .mozilla .thunderbird

 :    I want to correct this as quickly as possible, but I cannot 
 : find an option in the chmod man page that will ignore directories 
 : while changing all other files. There's probably a scripting 
 : approach using file and exec, but I've not done anything like 
 : this before so guidance on how to restore the appropriate perms 
 : will be very helpful.

As for recursively changing permissions, this is something that is 
always fraught with difficulty.  If you plan on managing your 
filesystems using unix tools regularly, then investing some time in 
learning the power of find, can pay dividends.

Here's a sample, but this is something that is worth 
experimentation.  Try this in a tmp directory or some sandbox before 
doing it for real.

Note, that I'm so nervous about these sorts of commands, that I 
sometimes throw an 'echo' in the command line to see what would be 
run.  I will do that below.  Anyway, here are some examples:

Change all directory permissions to 0700 (restrictive):

  find "$DIR" -type d -print0 \
    | xargs --null --no-run-if-empty -- echo chmod 0700 --

Change all file permissions to 0644 (standard permissive):

  find "$DIR" -type f -print0 \
    | xargs --null --no-run-if-empty -- echo chmod 0644 --

Change all files in this directory to 0600 (restrictive):

  find "$DIR" -mindepth 1 -maxdepth 1 -type f -print0 \
    | xargs --null --no-run-if-empty -- echo chmod 0600 --

These are just some quick tips.  The find manpage is extensive...of 
course, part of the problem is figuring out where to begin!  I would 
also note that there's a long-standing feud between people who 
suggest:

  find ... -exec {} \;

The more current crowd, who suggest:

  find ... -exec {} +

And, some who suggest:

  find  ... | xargs ...

In all of the above, I'm assuming GNU find, as well, which is subtly 
different from some of the other implementations of 'find' you may 
find in the field.

Best of luck in fixing your home directory!

-Martin

-- 
Martin A. Brown
http://linux-ip.net/
_______________________________________________
PLUG mailing list
[email protected]
http://lists.pdxlinux.org/mailman/listinfo/plug

Reply via email to