chmod and chown recursion (sudo)

Smoot Carl-Mitchell smoot at tic.com
Tue Mar 8 03:17:13 UTC 2011


On Mon, 2011-03-07 at 17:37 -0800, MR ZenWiz wrote:
> On Sat, Mar 5, 2011 at 5:55 AM, Thufir Hawat <hawat.thufir at gmail.com> wrote:
> > On Sat, 05 Mar 2011 06:06:37 -0700, Smoot Carl-Mitchell wrote:
> >>
> >> The umask bits are modifying the results when you do not specify the
> >> leading ugo flags.  I suspect root's umask is different than your own
> >> umask.  See the man page for details.  This should work if you really
> >> want to make the file tree readable and writable by everyone:
> >>
> >> sudo chmod -R ugo+rw  FaceletsEssentials
> >
> > I'll check the doc's, thanks.  I'm not familiar with umask.  Here are the
> > results of that command, which doesn't quite accomplish what I'd hoped
> > for:
> >
> 
> The umask is not involved when you do a chown or chmod.  The problem
> you are seeing is because ugo+rw does not give you execute (search)
> permission on the directories.  This is the correct command:
> 
> sudo chmod -R 777 <your directory here>
> 

Check the man page on chmod.  The umask does effect the results.  Also
the ugo+rw *adds* the bits indicated and does not affect bits already
set in the permission.

Try this:

smoot at smoot:~/tmp$ mkdir test
smoot at smoot:~/tmp$ umask
0002
umask only masks the "other" 'w' bit  -e.g. 2nd bit from the right.
umask = 000 000 000 010 in binary.

smoot at smoot:~/tmp$ cd test
smoot at smoot:~/tmp/test$ touch a b
smoot at smoot:~/tmp/test$ chmod 444 *
smoot at smoot:~/tmp/test$ ls -l
total 0
-r--r--r-- 1 smoot smoot 0 2011-03-07 20:02 a
-r--r--r-- 1 smoot smoot 0 2011-03-07 20:02 b
smoot at smoot:~/tmp/test$ chmod +w *
smoot at smoot:~/tmp/test$ ls -l
total 0
-rw-rw-r-- 1 smoot smoot 0 2011-03-07 20:02 a
-rw-rw-r-- 1 smoot smoot 0 2011-03-07 20:02 b

Note the "other" 'w' bit is unaffected by the chmod +w * command.

sudo which inherits the root users umask which is typically 022 will not
affect the 'w' bit for the group and other.

If the search 'x' bit was not set on a directory, you will get a
permission denied message as a normal user.  With sudo it overrides the
permissions, since it is running with root privileges.

-- 
Smoot Carl-Mitchell
System/Network Architect
voice: +1 480 922-7313
cell: +1 602 421-9005
smoot at tic.com





More information about the ubuntu-users mailing list