[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: NO! chmod strikes!



On Sun, Jul 08, 2001 at 10:14:12PM -0400, Paul D. Smith wrote:
> Both chmod -R and ls -R behave the same way.  However, your description
> above is not actually what happens, and I haven't seen anyone else here
> correct it in so many words.  So, just to be clear:
> 
> Remember that the shell expands all wildcards, not the application.  So,
> supposing you had these files/directories in your current working
> directory:
> 
>  .  ..  .foo  .bar  .biz  baz  boz
> 
> Then, the command "chmod -R o-rwx .*" is identical (from the point of
> view of chmod, which only gets the postprocessed commandline) to having
> typed this:
> 
>  chmod -R o-rwx . .. .foo .bar .biz
> 
> 
> _Neither_ ls nor chmod (nor any other tool that recurses that I've ever
> heard of) will follow ".." in a directory as it's recursing.
> 
> However, if you give ".." on the command line, of course it will operate
> on that directory just like it would any other directory on the command
> line.
> 
> The upshot is, "chmod -R o-rwx .." will change the permissions in the
> parent directory and all of its subdirectories, recursively; it will
> start from the directory above the current directory and walk down.
> 
> It will _NOT_ walk back _up_ the tree any further up from the parent.
> 
> Ditto for "find", "ls", "diff -r", etc. etc.
> 
> So, the what happened here depends on your working directory.  If you
> ran the command in /root (or any other directory which is an immediate
> subdirectory of /), then the chmod started at / and your entire system
> got chmod'd and your system is relatively screwed.
> 
> If you ran it from a deeper directory, say /root/foo, then only the files
> under /root were changed; that may be less terminal.

beware "One True Way". hmph:

> BTW, the best way to do what you wanted to do is this:
> 
>   $ chmod -R o-owx .[!.]*
> 
> That will change everything, recursively, beginning with a ".", except
> "." and "..".  Modern shells also accept the more standard RE format:
> 
>   $ chmod -R o-owx .[^.]*

hey. nice job. lucid, wide coverage, reasonable depth.

how 'bout wrapping that up into a newbiedoc on GLOBs and PATHs?

	http://newbieDoc.sourceForge.net/

hmm?

-- 
DEBIAN NEWBIE TIP #57 from Steve Kowalik <stevenk@hasnolife.com> 
:
Wondering HOW TO SET YOUR TIME ZONE? Your system clock may be
showing UTC or GMT but you want it to display PDT or whatever.
Just run "tzconfig" as root. (You're sure to have it on your
debian system already -- it's provided in package "libc6".)

Also see http://newbieDoc.sourceForge.net/ ...



Reply to: